-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global-error.js not catching exceptions as expected according to the official doc #53756
Comments
I'm experiencing same issue. At the moment only workaround is to use _error.js file inside /pages directory to handle exceptions. |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
Can you share a reproduction that where it couldn't catch and in which mode ( |
It took me an embarrassingly long time to repro this: https://github.com/lforst/next-global-error-bug The readme in that repo has the repro instructions. |
I did a similar reproduction. Maybe helpful? |
I believe that you are just generating the error in a way that shouldn't actually render the global-error.tsx? It is supposed to handle error generated in the rendering of the root layout right? Not sure about your repro @icazemier but it feels wrong to have it in a setTimeout like that (no async/await for a promise or anything). It feels correct that the page should render and then the error occurs. The way I've been able to get the error to actually show itself is to do something like this within the root layout:
And ofcourse make sure to The random throwing error snippet above also triggers the global-error when included in a ServerComponent used by the layout. |
## What This fixes when the deep nested routes throws a client side error, it can still be caught by the `global-error.js` ## How We should always resolve global-error from root app directory instead of current route's layout. Also fixed a bad test before where the gloabl-error.js is not located correctly Fixes #53756 Closes NEXT-1760
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 Binaries: Node: 18.16.1 npm: 9.5.1 Yarn: N/A pnpm: N/A Relevant Packages: next: 13.4.13 eslint-config-next: 13.4.13 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
n/a
To Reproduce
Describe the Bug
exception should be catched by global-error.js file, but not
Expected Behavior
excepted to be catched by global-error.js
Which browser are you using? (if relevant)
chrome
How are you deploying your application? (if relevant)
local
NEXT-1760
The text was updated successfully, but these errors were encountered: