Next.js: Render error handling gone with v4

Created on 13 Oct 2017  路  7Comments  路  Source: vercel/next.js

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior


An error page is shown when the react rendering tree throw an error in production

Current Behavior


A blank page is shown when the react rendering tree throw an error in production

Steps to Reproduce (for bugs)


  1. Render a page server side with no errors
  2. Render a page client side with no errors
  3. Navigate to a page that throw inside the render method.

Context


I'm not 100% sure, but I think that such logic was present with v3.
It could have been removed with https://github.com/zeit/next.js/commit/d19cc975f4be6bf1d1ef205950b5749f5e735d78#diff-1858c8296dd2b642c74271609cf701e7L40.

Your Environment


| Tech | Version |
|---------|---------|
| next | v4.0.2 |
| node | v8.1.4 |
| OS | MacOs |
| browser | Chrome |

Most helpful comment

Unfortunately there are no simple way to catch exception during SSR and our pages can be easily stuck at loading forever.

All 7 comments

+1

At least, I'm pretty happy with the new error mechanism of react@16: componentDidCatch. I do no longer have to hook into react internals to report exceptions to our log service.

@oliviertassinari Hi, do you know if componentDidCatch is supposed to work on the server? It works fine for me on the client, but if I refresh the page where there is an error, triggering server side rendering, the app comes back with a Next.js 500 instead of catching it and displaying my custom message. It kind of defeats the purpose of error boundaries :-/

Nevermind, found my answer: https://github.com/facebook/react/issues/10442

No componentDidCatch for SSR for now :(

@damusnet I didn't know about it. I need to give it as second look!

Unfortunately there are no simple way to catch exception during SSR and our pages can be easily stuck at loading forever.

@ex3ndr actually there are. I coded simple component https://github.com/zekchan/react-ssr-error-boundary

Was this page helpful?
0 / 5 - 0 ratings