Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Server Actions example does not work #967

Open
rburgst opened this issue Oct 2, 2024 · 8 comments
Open

Next Server Actions example does not work #967

rburgst opened this issue Oct 2, 2024 · 8 comments

Comments

@rburgst
Copy link
Contributor

rburgst commented Oct 2, 2024

Describe the bug

The next server action example does not work currently

https://tanstack.com/form/latest/docs/framework/react/examples/next-server-actions

<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve 'tunnel-agent' in '/home/projects/vbwimykwkg.github/node_modules/sharp'
<w> while resolving 'tunnel-agent' in /home/projects/vbwimykwkg.github/node_modules/sharp to a directory
 ✓ Compiled / in 5.9s (534 modules)
 GET / 200 in 6074ms
<w> [webpack.cache.PackFileCacheStrategy]

When submitting the form, the useTransform code blows up.

Your minimal, reproducible example

https://stackblitz.com/github/tanstack/form/tree/main/examples/react/next-server-actions?embed=1&theme=dark&preset=node&file=src/index.tsx

Steps to reproduce

  1. Open the stackblitz
  2. notice the sharp warning about tunnel-agent
  3. submit the form
  4. BOOM

Expected behavior

The example should work and the server action should be invoked.

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

  • OS: Mac OSX Sequoia
  • Browser: Arc

TanStack Form adapter

None

TanStack Form version

0.33.0

TypeScript version

5.6.2

Additional context

No response

@rburgst
Copy link
Contributor Author

rburgst commented Oct 2, 2024

In Stackblitz and codesandbox if I press the "Submit" button, I get
Image

@rburgst
Copy link
Contributor Author

rburgst commented Oct 2, 2024

ok, I got it to work with the sample:
https://stackblitz.com/edit/tanstack-form-bz8cz5?file=README.md

@anisharaz
Copy link

Am still getting the error and #967 (comment) this still have the issue , how did you get to work , what is the problem ?
Image

@rburgst rburgst changed the title Next Server action not called Next Server example does not work Oct 3, 2024
rburgst added a commit to rburgst/form that referenced this issue Oct 3, 2024
see Next Server example does not work TanStack#967
@rburgst
Copy link
Contributor Author

rburgst commented Oct 3, 2024

@anisharaz see the PR #970

@rburgst
Copy link
Contributor Author

rburgst commented Oct 3, 2024

Also for posterity: I have a next setup where also server side logging is shown in the browser console, however, for unknown reasons the logs from the server action never showed up in my browser console. They did show up in the server console though.
Also note that if you dont get your POST values on the action, then your <input> fields are missing the name attribute.

@rburgst rburgst changed the title Next Server example does not work Next Server Actions example does not work Oct 3, 2024
@anisharaz
Copy link

@rburgst Thankyou that fixed it , but a new problem arised or it exist am not sure, while submitting while the fields are empty the request goes to server and server validation invalidates the and responce with the message and client side validation run too. Does it makes sence to make to send request to server while the client validation is failing
Image
Image

@rburgst
Copy link
Contributor Author

rburgst commented Oct 5, 2024

@anisharaz this looks like a bug in tanstack form to me

@rburgst
Copy link
Contributor Author

rburgst commented Oct 5, 2024

actually, this is due to the fact that if you did not touch the form state then "canSubmit" is true, only once you make any modification then the validation state is updated, see also https://tanstack.com/form/latest/docs/framework/react/guides/validation#preventing-invalid-forms-from-being-submitted

rburgst added a commit to rburgst/form that referenced this issue Oct 19, 2024
see Next Server example does not work TanStack#967
Balastrong pushed a commit that referenced this issue Oct 19, 2024
see Next Server example does not work #967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants