next.js: Page crashes and "Error: Connection closed." appears

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.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.15.0
      npm: 9.5.0
      Yarn: 3.5.0
      pnpm: 7.27.0
    Relevant packages:
      next: 13.3.1-canary.4
      eslint-config-next: 13.2.4
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

/

To Reproduce

Navigate to a page

Describe the Bug

It’s very rare, but we sometimes get “Error: Connection closed.” errors that crash the whole page, on navigation to a page. “Application error: a client-side exception has occurred” appears. It seems to happen when traffic to our website is low. Our website is hosted on Vercel and we’re using app dir.

Screenshot 2023-05-04 at 14 42 28

It originates from either here: https://github.com/facebook/react/blob/aef7ce5547c9489dc48e31f69b002cd17206e0cb/packages/react-server/src/ReactFlightReplyServer.js#L579 or here: https://github.com/facebook/react/blob/aef7ce5547c9489dc48e31f69b002cd17206e0cb/packages/react-server/src/ReactFlightReplyServer.js#L579

Expected Behavior

This shouldn’t happen, or at least show the error.tsx error boundary.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Ran into this same issue. Adding the following to any page that was using Suspense fixed it for us:

export const revalidate = 0;

Good luck!

Hi, this might be related to https://github.com/vercel/next.js/pull/50060 which has been updated in v13.4.4-canary.10 of Next.js, please update and give it a try!

Can we not lock this issue to collect more feedback from other users?

Unfortunately this issue won’t be actionable unless a reproduction is provided. If none is provided the issue will be auto-closed. A new issue can be opened with a reproduction if anyone else runs into it.