Skip to content
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 handler (global-error.tsx) fails to catch errors in nested layouts #50119

Closed
1 task done
SiarheiLazakovich opened this issue May 21, 2023 · 8 comments · Fixed by #52573
Closed
1 task done
Labels
bug Issue was opened via the bug report template. locked

Comments

@SiarheiLazakovich
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
    Binaries:
      Node: 16.17.0
      npm: 8.15.0
      Yarn: 1.22.19
      pnpm: 7.1.0
    Relevant packages:
      next: 13.4.4-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5

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

https://codesandbox.io/p/sandbox/runtime-water-ylwcg0

To Reproduce

  1. open: https://codesandbox.io/p/sandbox/runtime-water-ylwcg0
  2. execute: yarn start (or yarn && yarn build && yarn start)
  3. see:
Screenshot 2023-05-21 at 13 34 39

Describe the Bug

After upgrading to version v13.1.7-canary.11 and newer, the global error handler (global-error.tsx) fails to catch errors that occur within nested layouts. When an error occurs in a layout, the global error handler is not triggered, and the error is not handled.

Expected Behavior

When any error occurs in the application, the global error handler (global-error.tsx) should be triggered regardless of the level of nesting in the layouts. The global handler should catch and handle errors at any level of layout nesting.
Same as was in 13.1.7-canary.10.

codesandbox with 13.1.7-canary.10: https://codesandbox.io/p/sandbox/crazy-lake-nw0qy7
Screenshot 2023-05-21 at 13 34 26

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@SiarheiLazakovich SiarheiLazakovich added the bug Issue was opened via the bug report template. label May 21, 2023
@RafalChojnowskiPagepro
Copy link

For me it doesn't catch error from root layout either

@kodiakhq kodiakhq bot closed this as completed in #52573 Jul 12, 2023
kodiakhq bot pushed a commit that referenced this issue Jul 12, 2023
Previously `global-error` only caught the error on client side, this PR adds the support for catching the errors thrown during client components SSR or server components RSC rendering.

Closes #46572
Closes #50119
Closes #50723
@llee1990
Copy link

llee1990 commented Jul 19, 2023

Still seeing this issue after upgrading to v13.4.10. Unable to catch errors from root layout. Only from root error.tsx

@KristineTrona
Copy link

Same here, updated to 13.4.10 and throwing an error in root layout does not display global-error.tsx

@subalee
Copy link

subalee commented Jul 21, 2023

Same here @13.4.11
image

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@subalee @SiarheiLazakovich @KristineTrona @llee1990 @RafalChojnowskiPagepro and others