vercel / next.js

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

App.getInitialProps runs unnecessary in case of a server error #51610

Open siloor opened 1 year ago

siloor commented 1 year ago

Verify canary release

Provide environment information

The issue is not environment dependant.

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

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/vercel/next.js/blob/canary/packages/next/src/client/index.tsx#L442

To Reproduce

-

Describe the Bug

This

return Promise.resolve(
        renderErrorProps.props?.err
          ? renderErrorProps.props
          : loadGetInitialProps(App, appCtx)

Should be

return Promise.resolve(
        renderErrorProps.err
          ? renderErrorProps.props
          : loadGetInitialProps(App, appCtx)

As err is stored not on renderErrorProps.props, just renderErrorProps.

Like this, a server error always calls App.getInitialProps on the client side.

Expected Behavior

In case of a server error, next should not call App.getInitialProps on the client side.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

sujalcodes3 commented 1 year ago

Can I make this code change? I want to make my first contribution. I am new to open source. Sorry if I said something wrong.