Next.js Discord

Discord Forum

Help getting error info in production in app router

Unanswered
Sinhala Hound posted this in #help-forum
Open in Discord
Sinhala HoundOP
I have an error that's happening when I run a build in production, but not when I run it in development (or even if I run a production build, with NODE_ENV=development).

How can I log the error without it being obfuscated in a production build? In pages router, I used to do this with an ErrorBoundary, but this particular error is coming from server components, which doesn't support Error Boundaries, as far as I can tell.

I tried adding an error.tsx file, but that doesn't seem to do anything, I'm assuming because it has to be a client component.

17 Replies

Western paper wasp
If by “obfuscation” you’re talking about the
An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details
message, you can find the error in your server logs
If by “obfuscation” you meant that you can’t tell what file/function the error is from, due to bundling and minifying, you could try doing your local build as
NODE_ENV=production next build --no-mangling

and see if you can reproduce, that might allow stack traces to give more useful info on where the error is coming from
Sinhala HoundOP
That message IS the server log - it doesn't provide any useful information about where that error is coming from
This message is completely useless:
❯ npm start

> ahr@3.16.1 start
> next start

   â–² Next.js 14.1.3
   - Local:        http://localhost:3000

 ✓ Ready in 468ms
 ⨯ [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.] {
  digest: 'DYNAMIC_SERVER_USAGE'
}
So it says a digest is available - which is the main question I asked above - how do I access that so I can log it?
Sinhala HoundOP
From what I can tell, the error is supposed to be caught by the client side error.tsx - it just isn't - the file isn't even accessed
yeah, that feature is just FUBAR
It doesn't work at all like described in the docs
Sinhala HoundOP
I'm going to end up disabling generateStaticParams, which was added to make the page not take a full second to re-generate the page on every single page request...
The page is loading now, but I get this long list of obfuscated error messages - keep in mind - this is the SERVER LOG ...
I can't understand the logic of obfuscating the error in server logs at all
Sinhala HoundOP
no, but that wouldn't explain anything - everything works perfectly in development mode
I really just want some way to see these errors
Sinhala HoundOP
I don't get a build time error - these are all runtime
(Also, I'm not using header() or cookies())