How to test `global-error.tsx`
Unanswered
Crème D’Argent posted this in #help-forum
Crème D’ArgentOP
I have a
To try and test the global error boundary, I've simply put a
How can test the global-error boundary and ensure it's working?
Here are the docs for the
global-error.tsx file implemented, and I'd like to test it out and see what it looks like when it renders, but I'm having an impossible time doing so. I've seen in documentation that global-error.tsx only does anything in production builds, so I've tried building my app and running next start.To try and test the global error boundary, I've simply put a
throw 'Error' statement in my root layout. But all I get is the generic white page with plain text (see photo attached):"Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 193452068How can test the global-error boundary and ensure it's working?
Here are the docs for the
global-error file https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-root-layouts4 Replies
Crème D’ArgentOP
Bump?
@Crème D’Argent Bump?
global error doesnt work for root layout. everything under it. put the throw somewhere else. There should never be any logic in root layout to fail anyway
Common Tern
@Crème D’Argent did you ever figure out how to trigger it in client components? I'm having a hard time ever seeing the error UI in NextJS 15+. No matter if I trigger from client component or server component outside root layout I always see the white generic error message.
Crème D’ArgentOP
are you specifically trying to trigger the global-error boundary?