Prevent Next from hiding error message in Production build
Unanswered
Bakharwal dog posted this in #help-forum
Bakharwal dogOP
Is there a way to prevent next from hiding the error message in production build? I want to expose it to the user.
Today in prod i'm getting:
Today in prod i'm getting:
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.
17 Replies
@Bakharwal dog Is there a way to prevent next from hiding the error message in production build? I want to expose it to the user.
Today in prod i'm getting:
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.
If you want to expose it to the user you need to catch the error and not throw an error object
try {
return ...
} catch (error) {
console.error(error)
return <ErrorUI msg={error instanceof Error ? error.message : "Unkonwn Server Error Occurred"}/>
}
Bakharwal dogOP
I am catching the error , it still seems like next is masking it for some reason
cc @Alfonsus Ardani
@Bakharwal dog cc <@194128415954173952>
hmm thats weird, let me try it in a moment (thanks for the CC, but you can just reply my message)
Bakharwal dogOP
any news? 😄
build succesfull, errror successfuully caught
Bakharwal dogOP
in localhost, what about a production build?
Bakharwal dogOP
interesting
can you try to export a function that does it for you in another file, where in the begining of the file there is
use server
?can you help me with that? wdym?
Bakharwal dogOP
the try catch part, put it in a function in another file and put
use server
at the topyou should be able to test it yourself
Bakharwal dogOP
thanks!