-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undesirable custom error page behaviour (output + re-fetching data client-side) #47978
Comments
Hi, thank you for the issue. I've faced the same problem... |
@TasukuUno you could check out the attached PR for a solution. |
Ah, sorry, just noticed 12.x. The PR is for 13. I'm not sure how much that file has changed but you might be able to apply the same fix on 12. |
@tills13 Thank you for your response! |
Fixes: #47978 When an error occurs in getInitialProps, the error page's getInitialProps is run server-side and returned in `__NEXT_DATA__`. Following, there's no need to re-run `getInitialProps` client-side on the hydrate pass. --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023 Binaries: Node: 16.20.0 npm: 8.19.4 Yarn: N/A pnpm: N/A Relevant packages: next: 13.2.5-canary.30 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Data fetching (gS(S)P, getInitialProps)
Link to the code that reproduces this issue
https://github.com/tills13/nextjs-error-behaviour-reproduction
To Reproduce
NODE_ENV=production npx next build && npx next start
/
Describe the Bug
getIntialProps
client-side on the initial render resulting in a mismatch between server HTML and client HTML. This behaviour is different from other pages. Additionally, theerr
received by gIP client-side is different from the error received server-side. I recognize that it cannot be the same instance / class / whatever due to it needing to be serialized. This is more of a nit than anything as the desirable solution would be to just not re-run gIP client-side (see Expected Behaviour)Re-running gIP client-side also means that long running
getInitialProps
prevents JavaScript from running client-side untilgetInitialProps
resolves. I have left some commented code in_error
to demonstrate this.Expected Behavior
getIntialProps
client-side for a server-side error. I'm not too upset about this as our app gIP is fast, but it can result in the server HTML flashing before the client HTML settles.Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
next start
The text was updated successfully, but these errors were encountered: