Failed to find Server Action
Unanswered
Blanc de Hotot posted this in #help-forum
Blanc de HototOP
Error: Failed to find Server Action "3ae3a7930c6b6213c9cf94c89d08721c40f2f7bb". This request might be from an older or newer deployment. Original error: Invariant: Couldn't find action module ID from module map.Next.js version: canary, latest and in all versions 14+
When I build and start my Next.js project, it shows this error when calling a server Action from the client.
registerOptions(name)
.then((options) => {
if (!options) throw new Error();
return startRegistration(options);
})
.then((res) => verifyRegistrationOptions(res))
.then((res) => {
if (!res) throw new Error();
toast.success("Registered successfully! TEMP");
})
.catch((err) => {
setButtonDisabled(false);
toast.error("Something went wrong!");
});I am running the code snippet above. registerOptions is being called, but the function
verifyRegistrationOptions in the 2nd .then() is not being called and is throwing the error shown at the top.15 Replies
Hey ! Can you show a little more of the code, the verifyRegistrationOptions and how you import it ?
Can you verify you used "use server" on top of the server action file ?
Can you verify you used "use server" on top of the server action file ?
This error mostly occurs when you have an old version of your app running
@Cuvier’s Dwarf Caiman Can you try closing the tab you used in dev, and then creating a new tab.
Blanc de HototOP
I tried in another browser and a fresh incognito tab. I removed the cache (.next, .vercel) and node_modules as well. It still didn't work
@walid-mos Hey ! Can you show a little more of the code, the verifyRegistrationOptions and how you import it ?
Can you verify you used "use server" on top of the server action file ?
Blanc de HototOP
https://github.com/PranjalG1122/Tremble/blob/main/app/login/page.tsx#L72
The link above has the frontend page that uses the function.
https://github.com/PranjalG1122/Tremble/blob/main/lib/ServerActions/register.ts#L77
This link contains the function itself, and the file has "use server" at the top. The function name is actually
The link above has the frontend page that uses the function.
https://github.com/PranjalG1122/Tremble/blob/main/lib/ServerActions/register.ts#L77
This link contains the function itself, and the file has "use server" at the top. The function name is actually
verifyRegisterOptions.I know that in react you can call an arrow function and pass default parameters by only doing {function}, but are you sure you can do it inside code ? can you try to call
res => verifyRegisterOptions(res) instead ?@walid-mos I know that in react you can call an arrow function and pass default parameters by only doing {function}, but are you sure you can do it inside code ? can you try to call res => verifyRegisterOptions(res) instead ?
Blanc de HototOP
I tried this as well, still the same error.
Ah yes this error is a known bug, you should try to import the server action in a parent server component, and pass it to the client component as a prop !
https://github.com/vercel/next.js/discussions/58431#discussioncomment-7620263
https://github.com/vercel/next.js/discussions/58431#discussioncomment-7620263
@walid-mos Ah yes this error is a known bug, you should try to import the server action in a parent server component, and pass it to the client component as a prop !
https://github.com/vercel/next.js/discussions/58431#discussioncomment-7620263
Blanc de HototOP
I tried the fix in this post, it still didn't work.
I did some testing, if I run two consecutive server actions, then it throws an error during the second one, whether I chain them in
.then() or use async/await.Blanc de HototOP
Ok, so I was able to fix this issue, for anybody who sees this in the future.
After Next.js 14.1.0, middleware is invoked when server actions are called. My code would set a token in
After Next.js 14.1.0, middleware is invoked when server actions are called. My code would set a token in
registerOptions which would cause the middleware to be confused when it ran the next function.Knopper gall
ultra necro
i had 2 server actions in parallel
1 was updating a cookie and 1 was updating supabase
problem was that after updating the cookie middleware was triggered like oyu mention, app was redirecting to another page and second request for updating supabase was canceled dropped idk but was not inserting into database
1 was updating a cookie and 1 was updating supabase
problem was that after updating the cookie middleware was triggered like oyu mention, app was redirecting to another page and second request for updating supabase was canceled dropped idk but was not inserting into database
and was getting server action with id X not found etc etc