-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Ensure we rerender after a suspensefully hydrating boundary throws an… #4856
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
Conversation
📊 Tachometer Benchmark ResultsSummaryA summary of the benchmark results will show here once they finish. ResultsThe full results of your benchmarks will show here once they finish. |
|
Size Change: +221 B (+0.28%) Total Size: 78.9 kB
ℹ️ View Unchanged
|
b8fee2d to
c56d363
Compare
c56d363 to
dec937f
Compare
rschristian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find!
marvinhagemeister
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Consider the following scenario, we have an application with a shell:
We server-side render the HTML, send it to the client. The client starts hydrating and we do that successfully up to the
Body, theBodywill throw a Promise and we'll suspend. This means that the Header/Footer will be interactive the the Body won't be, when Body loads we continue hydration but there is an error in the component.When there is an error we remove the existing DOM as hydration is considered useless and we need to render the
ErrorBoundary. When theErrorBoundaryis set toretryimmediately we'll attempt to re-render the component. With Signals (and PureComponent/...) there's a chance that we now bail out of rendering, we'd bail out of rendering while having a partially mutated oldVNode. The oldVNode would signal that it has_componentand hence is not new while being absent from_childrenas we never reacheddiffChildren.This PR will ensure that when we error that we must consider the update as forced, this ensures that we never bail out of rendering and that any erroneous state that could be in the component is reset.
Initially I had a simpler solution where I would set
vnode._componentto null but that means that we'd break components catching their own error. Hence why I got to a solution that requires a bit more bytes but solves most of the issues. In reality theelsebranch isn't really needed for the issue at hand but I'd prefer being safe.Big thanks to @joel-solymosi for finding this issue and providing the hints we needed.
The issue was introduced in #4563
Supersedes #4854
Supersedes #4822