-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Potential for infinite error loop during client-side hydration #39461
Comments
Hi, good catch! I opened a PR to ensure we can properly handle this case here #39467 |
This seems to be a regression introduced in |
The fix that closed this issue is only available in |
This closed issue has been automatically locked because it had no new activity for a month. 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
What browser are you using? (if relevant)
Chromium 104.0.5112.81 (Official Build) (arm64)
How are you deploying your application? (if relevant)
N/A
Describe the Bug
For the following simplified application structure:
pages/
index.js
(with getServerSideProps)_app.js
_error.js
(with getServerSideProps)in production, if there is an error within a page's
getServerSideProps
call (e.g.index.js
), the app will fallback to rendering the_error.js
page.Assuming that the
_error.js
file successfully callsgetServerSideProps
and renders the error component, that content will be flushed to the browser. (no issue here yet)When that error page is hydrated on the client, Next logs that there was a 500 error on the server (because of the error in
index.js
'sgetServerSideProps
) and attempts to render the component.Through that rendering process, Next tries to call
getInitialProps
on either the_app
component or the page it was rendering (in our case_error
), if neither exist it returns an empty object.This empty object then breaks our assumption within
_app
where we expect to have the props returned from eitherindex.js
's or_error.js
'sgetServerSideProps
, so when that data isn't there it throws.The loop then continues here because the top level error boundary (
Container
component in next's lib/client/index.tsx file) attempts to retry rendering the fallback page, re-entering the error loop above.Expected Behavior
If an error occurs during hydration, try to re-render only a limited number of times (that could be only trying to render it once, or maybe not even trying to re-render the page).
Link to reproduction
https://github.com/hamlim/next-error-clientside-loop
To Reproduce
yarn install
yarn build
yarn start
localhost:3000
and open dev tools to see the loop of errors happeningThe text was updated successfully, but these errors were encountered: