Next.js: Regression in client-side handling of error pages since v2.1.1

Created on 25 Apr 2017  路  8Comments  路  Source: vercel/next.js

After upgrading to v2.2, I noticed that, on production builds, Next is rehydrating the routes for pages that errored during SSR. Steps to reproduce:

  1. Make a trivial page to trigger an error state:
import React from 'react'

export default class NewTest extends React.Component {

    static async getInitialProps({ res }) {
        throw new Error('Test Error');

        return {foo: 123};
    };

    render() {
        return <div>
            This page should always throw an error: {this.props.foo}
        </div>
    }
}
  1. Navigate to this page via Link on client-side. You should see the error page as anticipated.
  2. Refresh the page, allowing SSR to take over.

Observations:

  • Error is displayed quickly, then is replaced by the output of render() in the view above.
  • this.props.foo is not filled, leading me to think Next is skipping getInitialProps for initial rehydration purposes, thus missing the error.
  • ...but, I wouldn't expect it to run this view at all if the server wasn't able to render it. I never want users to see a flash of content, and it makes tracking the issue more difficult.
  • Backing up to v2.1.1 fixes the issue, but I haven't isolated further than that.
bug

Most helpful comment

I can reproduce this.
Thanks.
Let's see what we can do about this.

All 8 comments

@arunoda this appears to have been introduced with #1700

@gcpantazis That was a huge change.
Let me check.

I tested. I couldn't reproduce it with 2.2.0
pctvesg0zt

Would you mind sending me a sample repo?

@arunoda that's development-mode, I think? This is only happening on production builds (next build && next start), dev looks fine (like your vid).

Let me know if you can't repro on a production build, I'll put together a repo to demo what I'm seeing if not.

Let me check.

I can reproduce this.
Thanks.
Let's see what we can do about this.

@gcpantazis we'll have the fix in the next patch release.

Thanks @arunoda! assetPrefix is a huge help for us, so this is very much appreciated 馃檱

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesselee34 picture jesselee34  路  3Comments

renatorib picture renatorib  路  3Comments

rauchg picture rauchg  路  3Comments

DvirSh picture DvirSh  路  3Comments

olifante picture olifante  路  3Comments