Repository navigation
Conversation
|
The build for this commit did not complete, so there is no size report. See the workflow run for details. Generated by sizebot against d23f606 |
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #37551.
If something inside
<head>suspends during hydration, everything after it stops hydrating. The server-rendered nodes in<body>get thrown out and rebuilt on the client.<head>is a scope - entering stashes the hydration cursor, exiting restores it. When a child suspends,replayBeginWorkre-runsbeginWorkon the same fiber, so<head>gets claimed a second time without having exited, and that claim clobbers the stashed cursor.replayBeginWorkalready restores hydration state forHostComponent(#35494). This does the same forHostSingleton.#35494 does have a
HostSingletontest, but its lazy child sits in<body>- a singleton with no scope, so the cursor never gets touched. That's how<head>slipped through.HostHoistableisn't included, it can't suspend this way.unwindWorkstill has its// TODO: popHydrationState, left alone.Different approach: a three-line fix that just skips the save when the slot's full. Same tests pass. But went with the restore since it's the reconciler that skipped the exit.
How did you test this change?
Added three tests to
ReactDOMServerPartialHydration-test.internal.jsnext to the #35494 ones - empty<head>,<head>with server-rendered content, and<head>replayed twice. Each checks there's no recoverable error and thatdocument.body.firstChildis still the same node, i.e. it actually hydrated instead of getting replaced.On main:
With the fix. Run them one at a time — they hydrate
document, so a leftover rootfrom an earlier test in the file hides the failure:
I also ran the repro from the issue as-is against published
[email protected].headis the reported case,bodyis its control:Full sweep at
9b93853278: