-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
[BUG] [Next 15] Dev/build error: Server Actions must be async functions #288
Comments
Yep, unfortunately that's the current behavior of Next.js 15, not sure if it's a bug or expected, I'm waiting for an official reply by the Next.js team. Check out this tweet. |
Yeah, pretty sure this is a bug. I build a similar library myself, and I'm getting the same thing as well. What I noticed is that it only happens when Next.js encounters a "top-level" function within a For instance: "use server";
export action =
client
.method(() => {}) // This the top-level function to Next.js bundler, and it has to be an async function
.method2(() => {}) // This the top-level function to Next.js bundler, and it has to be an async function The workaround is also simple, just mark them as async function. The only problem is that your linter might not like it. |
Yup. Build issue doesn't makes any sense. |
Hey @chungweileong94, thanks for opening an issue in the Next.js repo. I'm linking it here for reference, as this issue is related to the framework itself rather than next-safe-action. |
any workaround for the time being? just started a new project and stuck because of this |
You should be able to workaround the issue by adding |
can you give me an example, this is the first time, I'm using this library |
Unfortunately, it's really depends on what kind of code you have. Mind if you can share me the code snippet? |
I'm just adding contact form, heard about the library few months ago, wanted to try today, this is what I implemented so far using the docs,
|
Ah I see, I think this doesn't share the same problem as this issue. Basically, in your case you just have to remove the |
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
I just upgraded to Next.js 15 and I got this at
handleValidationErrorsShape: async (ev) => flattenValidationErrors(ev)
saying that this has to be an async function. To mitigate this issue I added the async keyword. However, there's a race condition within next that I have to click the submit button twice to actually get back any validation errorsReproduction steps
Upgrade to next Next 15 and use
handleValidationErrorsShape
on a server actionExpected behavior
No error at all
Link to a minimal reproduction of the issue
https://github.com/Caramella-Corner/caramellacorner.shop/blob/master/app/admin/_actions/products.ts
Operating System
Windows 11
Library version
7
Next.js version
15.0.1
Node.js version
20.18.0
Additional context
No response
The text was updated successfully, but these errors were encountered: