Skip to content

Commit 54ed081

Browse files
committed
fix(hydration): mark range end after single-root discard so later siblings stay quiet
When a hookless single-root clone discards a mismatched server node, discardCursor advances the adoption cursor to the next sibling. If that sibling is the enclosing range-end marker, it was never recorded in HYDRATION_REBUILT, so a later sibling's firstAtRangeEnd call returned true and emitted a duplicate mismatch diagnostic for the same recovery. Mark the range end after discardCursor, matching the pattern already used by rebuildFragment. Add a SingleThenTally fixture that fails without the fix (two warnings instead of one in dev mode).
1 parent eeae6f8 commit 54ed081

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19966,6 +19966,8 @@ class HydrationCapability {
1996619966
return this.freshClone(template);
1996719967
}
1996819968
this.discardCursor(cursor);
19969+
if (this.node != null && isBlockClose(this.node))
19970+
this.remember((HYDRATION_REBUILT ??= new WeakSet()), this.node);
1996919971
if (claimsRoot)
1997019972
this.claimRootRemainder(
1997119973
framedRemainder === undefined ? (unframedRemainder ?? null) : framedRemainder,

‎packages/octane/tests/hydration/_fixtures/component-range-siblings.tsrx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ function TallyThenSingle() @{
6262
</>
6363
}
6464

65+
function SingleThenTally() @{
66+
<>
67+
<Single />
68+
<Tally name="inner2" />
69+
</>
70+
}
71+
6572
function TallyThenIf() @{
6673
<>
6774
<Tally name="inner" />
@@ -77,6 +84,7 @@ const CONTENT: Record<string, ComponentType<{}>> = {
7784
PlainThenTally,
7885
TallyThenSingle,
7986
TallyThenIf,
87+
SingleThenTally,
8088
};
8189

8290
// A component named by `value`, or else `value` itself as text.

‎packages/octane/tests/hydration/component-range-siblings.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ describe.each([
210210
expected: 'a component range',
211211
actual: 'text "server"',
212212
},
213+
{
214+
when: 'a hookless single-root precedes a component',
215+
name: 'Content',
216+
server: { value: 'server' },
217+
client: { value: 'SingleThenTally' },
218+
expected: '<i>',
219+
actual: 'text "server"',
220+
},
213221
{
214222
when: 'an @if arm follows the first component',
215223
name: 'Content',

0 commit comments

Comments
 (0)