Skip to content

"A client-side exception has occurred" logged if _error.tsx page defines a getInitialProps #38609

@gazs

Description

@gazs

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
Binaries:
  Node: 16.13.2
  npm: 8.7.0
  Yarn: 1.22.15
  pnpm: 6.11.0
Relevant packages:
  next: 12.2.3-canary.5
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

warn - Failed to fetch latest canary version. (Reason: Cannot read properties of undefined (reading 'tag_name').)
Detected "12.2.3-canary.5". Visit https://github.com/vercel/next.js/releases.
Make sure to try the latest canary version (eg.: 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

What browser are you using? (if relevant)

n/a

How are you deploying your application? (if relevant)

next start

Describe the Bug

If I define a custom error page following the instructions on https://nextjs.org/docs/advanced-features/custom-error-page#more-advanced-error-page-customizing, the built app will log the following error to console:

 {
    "name": "Internal Server Error.",
    "message": "500 - Internal Server Error.",
    "statusCode": 500
}
A client-side exception has occurred, see here for more info: https://nextjs.org/docs/messages/client-side-exception-occurred

Defining an client-side ErrorBoundary has no effect, in fact it seems to be mounting later than this error message being logged.

Screenshot 2022-07-13 at 16 16 49

Expected Behavior

I should see no error after following the documentation.

Link to reproduction

https://codesandbox.io/s/epic-flower-kydj8s?file=/pages/_error.tsx

To Reproduce

  1. build next app and start it (or open codesandbox link above)
  2. visit localhost:3000
  3. see error message in console
  4. see ErrorBoundary rendering after the error is logged and saying there are no errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions