Next.js Discord

Discord Forum

throwing error is server action is not working in production

Unanswered
Mini Rex posted this in #help-forum
Open in Discord
Original message was deleted.

4 Replies

Mini Rex
i am trying to throw error from server action and catching it in client it is working on development but it is not in production
it is giving me given below error:-
An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.

code is basically this :-
"use server"
export function action(){
if(somethingWentWrong)
throw new Error("unable to perform this task");
return ....;
}

in client side
"use client"
function Compo(){
async function onClick(){
  try{
  await action();
  }catch(err){
   console.log(err.message);
  }

///...some things render
}
can anyone tell me why?
Your server action is not an async function?
handle errors in server actions like this https://github.com/vercel/next.js/discussions/49426
Mini Rex
thank you i got it