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

Issue with Global Error Handling in page.tsx and global-error.tsx #50723

Closed
1 task done
mieaw opened this issue Jun 3, 2023 · 1 comment · Fixed by #52573
Closed
1 task done

Issue with Global Error Handling in page.tsx and global-error.tsx #50723

mieaw opened this issue Jun 3, 2023 · 1 comment · Fixed by #52573
Labels
bug Issue was opened via the bug report template. locked

Comments

@mieaw
Copy link

mieaw commented Jun 3, 2023

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.1.7-canary.10
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

warn  - Latest canary version not detected, detected: "13.1.7-canary.10", newest: "13.4.5-canary.4".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue
Done in 2.87s.

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/github/vercel/next.js/tree/canary/examples/reproduction-template-app-dir

To Reproduce

See Code: https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template-app-dir

Describe the Bug

In page.tsx, we have throw Error("Nha!!"); on line 3.

I added global-error.tsx to catch all errors as mentioned in the documentation.

Expected Behavior

If we add error.js, it will work, but it seems that global-error.tsx is not functioning correctly.

From docs (https://nextjs.org/docs/app/building-your-application/routing/error-handling):
global-error.js serves as the least granular error UI and can be considered the "catch-all" error handling for the entire application. It is unlikely to be triggered often since root components are typically less dynamic, and other error boundaries defined in error.js will catch most errors.

Even if global-error.js is defined, it is still recommended to define a root error.js file. The fallback component of the root error.js will be rendered within the root layout, which includes globally shared UI and branding.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Version 114.0.5735.90 (Official Build) (64-bit)

@mieaw mieaw added the bug Issue was opened via the bug report template. label Jun 3, 2023
@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
@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 11, 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.

1 participant