vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.97k stars 26.87k forks source link

Failed request to /_next/data during CSR triggers generic error instead custom error page #48974

Open karoun opened 1 year ago

karoun commented 1 year ago

Verify canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #29-Ubuntu SMP Fri Dec 16 06:28:18 UTC 2022
Binaries:
  Node: 16.17.0
  npm: 8.15.0
  Yarn: 1.22.17
  pnpm: N/A
Relevant packages:
  next: 12.3.1
  eslint-config-next: N/A
  react: 17.0.2
  react-dom: 17.0.2

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

Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue

https://github.com/reactjs/react.dev

To Reproduce

  1. Load https://react.dev/learn
  2. In browser dev tools Network tab, block requests to /_next/data/*
  3. Click "Thinking in React"
  4. A generic "Application error" is shown, rather than "Something went wrong" (https://react.dev/500)

Describe the Bug

When a client-side transition (via router.push() or next/link) fails (due to the network request to /_next/data failing), a generic Next error page is shown.

This is problematic because the generic Next error page is unbranded and quite technical (Application error: a client-side exception has occurred (see the browser console for more information).) and therefore not a good user experience.

Expected Behavior

I would expect Next to trigger a redirect to the originally-requested URL, rather than bubbling up a client-side error. That would have the effect of loading the non-generic error page (_error, if available).

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

hmelii commented 1 year ago

This bug was fixed in v13.4.0

karoun commented 1 year ago

Excellent news, thank you @hmelii! Could you link to the fix in question?

rbruggem commented 9 months ago

I am facing the same issue on v14.0.3. Same outcome, however, happens when requests on /_next/image?url=xxx fail.