next.js: Client error handler should not run on initial render

I have a site that only supports modern browsers. Old browsers can still access the content thanks to server rendering, which is great. The problem is that Next currently renders an error page when an exception is thrown during render.

So, in an old browser:

  1. Navigate to the site
  2. Server renders the page
  3. Client displays the server-rendered page
  4. Client runs the client script. The page component uses an API like Object.assign, causing an exception to be thrown in the old browser.
  5. Next switches to the error view, hiding the original content.

My preference would be for Next to ignore exceptions during the initial page load so that old browsers will continue displaying the server-rendered content. I can work around this by loading polyfills (that I don’t need for my target users), but it’d be nice if I could avoid this.

FWIW, I ran into this because Googlebot apparently runs a very old version of Chrome, and was seeing the error page after one of my views tried to use Object.assign.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Agree with @hyperborea. Also having challenges with this. We have audiences in emerging markets using browsers like opera mini and UC browser which are already challenging enough to debug.

Sad to see this ticket has been closed with no real solution. I’ve been running into missing polyfills a couple of times now and have found no good way to debug / error log “an unexpected error has occurred” exceptions caused by issues in client side rendering. It would be nice to at least fallback to the SSR version in these cases.

I understand as well if you don’t want to change default behaviour of next, but some toggle or escape hatch would be really appreciated.