Next.js Discord

Discord Forum

Server component throw error on production

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
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.

this is only apply on production whenever throws an error message

11 Replies

can't really say what's the issue
without seeing error
Asiatic LionOP
e.g
"use server"
export async function doSomeThing() {
  if(false) {}
  else {
    throw new Error("An Error Message");
  }
}


throwing error from server actions. works as expected on dev mode.
but when start on production it throws this message instead of our error message
expected message An Error Message
actual message 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.
you need to catch that error somewhere
in dev, you would just get shown dev error popup
Asiatic LionOP
i catch the error on the client component as well using try {} catch (error) {}
@averydelusionalperson https://nextjs.org/docs/app/building-your-application/routing/error-handling
Asiatic LionOP
can you highlight which part should help fix this issue from the link ?
Arboreal ant
Check your logs to see what the error is for that digest. The error should have a short id which should make it easy to filter the logs.
Asiatic LionOP
I tried to delete digest property from error object incase exist but still the same issue on production.
I'll give @joulev solution a try. i think it should works