TheEdoRan / next-safe-action

Type safe and validated Server Actions in your Next.js project.
https://next-safe-action.dev
MIT License
2.21k stars 35 forks source link

[BUG] [Next 15] Dev/build error: Server Actions must be async functions #288

Open monstajoe2002 opened 4 days ago

monstajoe2002 commented 4 days ago

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 errors image

Reproduction steps

Upgrade to next Next 15 and use handleValidationErrorsShape on a server action

Expected 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

TheEdoRan commented 4 days ago

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.