Repository navigation
fix(hydration): report a mismatched range once across sibling components - #1585
Merged
Merged
Conversation
When a server range holds content the client does not render, such as
server text in a hole whose client value is a component that renders two
component calls, the first call reports the server node, discards it up
to the end of the range, and builds between fresh markers. Every later
sibling then found the cursor on that range end and reported again ("the
server rendered the end of the parent block"), so one recovery logged a
dev diagnostic per sibling.
Remember the range end in HYDRATION_REBUILT once a recovery reaches it.
renderUnframed (component slots), the fragment and single-root template
claims that find the cursor on a range end, and rebuildFragment now share
firstAtRangeEnd, so only the first claim at that end reports. A mismatch
in a separate range still reports on its own.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CkBkcRuEtVuENx2eTJF9Gv
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Single-root discard skips range-end mark
- After discardCursor in the single-root mismatch path, the adoption cursor can land on the enclosing range-end marker without recording it in HYDRATION_REBUILT; adding the same remember call used by rebuildFragment prevents later siblings from emitting a duplicate diagnostic.
Or push these changes by commenting:
@cursor push 54ed0819ac
Preview (54ed0819ac)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -19966,6 +19966,8 @@
return this.freshClone(template);
}
this.discardCursor(cursor);
+ if (this.node != null && isBlockClose(this.node))
+ this.remember((HYDRATION_REBUILT ??= new WeakSet()), this.node);
if (claimsRoot)
this.claimRootRemainder(
framedRemainder === undefined ? (unframedRemainder ?? null) : framedRemainder,
diff --git a/packages/octane/tests/hydration/_fixtures/component-range-siblings.tsrx b/packages/octane/tests/hydration/_fixtures/component-range-siblings.tsrx
--- a/packages/octane/tests/hydration/_fixtures/component-range-siblings.tsrx
+++ b/packages/octane/tests/hydration/_fixtures/component-range-siblings.tsrx
@@ -62,6 +62,13 @@
</>
}
+function SingleThenTally() @{
+ <>
+ <Single />
+ <Tally name="inner2" />
+ </>
+}
+
function TallyThenIf() @{
<>
<Tally name="inner" />
@@ -77,6 +84,7 @@
PlainThenTally,
TallyThenSingle,
TallyThenIf,
+ SingleThenTally,
};
// A component named by `value`, or else `value` itself as text.
diff --git a/packages/octane/tests/hydration/component-range-siblings.test.ts b/packages/octane/tests/hydration/component-range-siblings.test.ts
--- a/packages/octane/tests/hydration/component-range-siblings.test.ts
+++ b/packages/octane/tests/hydration/component-range-siblings.test.ts
@@ -211,6 +211,14 @@
actual: 'text "server"',
},
{
+ when: 'a hookless single-root precedes a component',
+ name: 'Content',
+ server: { value: 'server' },
+ client: { value: 'SingleThenTally' },
+ expected: '<i>',
+ actual: 'text "server"',
+ },
+ {
when: 'an @if arm follows the first component',
name: 'Content',
server: { value: 'server' },You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit eeae6f8. Configure here.
…n-op6rqr # Conflicts: # packages/octane/src/runtime.ts
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (19 within noise)
Application bundle size (bytes)No changes across 45 measured values. Public-import reachability bundles (bytes)
95 other measured values are unchanged. |
A single-root clone that mismatches a server node rebuilds over it and steps the cursor past it. When that step lands on the end of the server range, a later sibling there still reported a second "the server rendered the end of the parent block" diagnostic for the same recovery (Cursor Bugbot). Record that end as rebuilt, as rebuildFragment does, through a shared reachedRangeEnd. The GateForm/RootForm controls in the suspended-clone suites are this case (<s> rebuilt over <b>, then <i> at the range end), so they now publish one diagnostic; the suspended attempts still match them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CkBkcRuEtVuENx2eTJF9Gv
trueadm
marked this pull request as ready for review
October 2, 2026 18:46
…n-op6rqr Resolve renderUnframed against #1589, which mints the fresh markers in place of the stale server nodes and stops the discard at a later sibling's range. The discard can no longer reach the fresh markers, so the range-end check reads the node it stopped on directly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n-op6rqr Resolve adopt's single-root mismatch path against #1593: keep the PR's atRangeEnd check and reachedRangeEnd mark alongside #1593's lite-host parent guard and lite endMarker step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
Resolve runtime.ts against #1585 and #1599. #1585 reports a mismatched range once across sibling components: the discard runs before the report, which is skipped when the discard stopped at a range end an earlier recovery already reported (firstAtRangeEnd). renderUnframed keeps that order with this branch's discardInPlace, which returns where it stopped. placeRebuilt's in-place discard also records a range end it reaches (reachedRangeEnd), as its other discard does. #1599 names the static root after a fragment's leading holes in the rebuilt-fragment warning. That warning now lives in placeRebuilt, so it takes the template from the rebuilt record and keeps the lite call's site. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 2, 2026
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
Some hydration mismatches logged one dev diagnostic per component instead of one per recovery. This happens when a server range holds content the client doesn't render, and the client renders several sibling component calls in that range.
Example: the server renders text
"server"in a{hole}, and the client's value for that hole is a component that renders two<Tally />calls.Once a recovery reaches the range's closing marker, this change records that marker in the existing
HYDRATION_REBUILTset, and only the first claim there reports (firstAtRangeEnd). Inpackages/octane/src/runtime.ts, these places report throughfirstAtRangeEnd:renderUnframed: component slots fromcomponentSlotImpl, plus anchorless lite calls.adopt(): a fragment template that finds the cursor on a range end.adopt(): a single-root template that finds the cursor on a range end. This combines withmain's retry check (cursor !== this.replaced).These record the marker without reporting again, through
reachedRangeEnd:rebuildFragment, when its discard reaches the range end.adopt()'s single-root rebuild, when stepping past the replaced server node lands on the range end. This was Cursor Bugbot's finding.A mismatch in a separate range still reports.
onRecoverableErroralready fired once per hydration burst, so the duplicate only ever appeared in the dev console. The adoption fast path is unchanged; only mismatch-recovery branches moved.New coverage:
tests/hydration/component-range-siblings.test.tswith fixture_fixtures/component-range-siblings.tsrx, run under both the dev and prod compile. Cases:button.afteradopted, every component responds to clicks, and the hole swaps back and forth.@iffollowing the first component.Changed expectations: the
GateForm/RootFormnever-suspends controls insuspended-clone-mismatch.test.tsandroot-suspended-clone-mismatch.test.tsare the single-root case. There,<s>is rebuilt over<b>, then<i>lands on the range end. Their pinned dev count goes from 2 to 1, and the suspended attempts still match the controls.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkis clean on the changed files.pnpm typecheck: not run repo-wide.pnpm typecheck:files packages/octane/src/runtime.tsis clean.pnpm test: not run. I ran vitest--project octane --project octane-prodon the first commit: 37,068 passed and 4 failed. The 4 failures are 2 tests inbehavior-root.test.ts("getter reentry, abort and recovery"), run in both projects. They fail the same way on the base commit fdf54fe in this container, which runs Node 22.22.0 while the repo asks for ≥22.22.2.mainat 0b0e10f,packages/octane/tests/hydrationplusauto-memo-value-position.test.tspass in both projects: 260 files, 12,530 tests.main'sruntime.ts, the new suite fails 10 of 22 tests (all dev-compile diagnostic assertions); with this change all 22 pass.pnpm syncproduced no changes.Bundle bytes (
node benchmarks/bundle-size/run-minimal.mjs, and CI's benchmark report):hydrate-rootanddeferred-hydrationeach grow by about +247 raw and +62 to +83 gzip bytes.hydrate-rootwas already over its committed budget on the base commit, and CI doesn't gate that fixture.Risk / follow-ups
HYDRATION_REBUILTset is documented to do. A root attempt that rolls back, or a discarded speculative attempt, forgets the entry through the existing journal/undo.behavior-rootfailures above predate this change and are untouched here.Provenance
agent-authored)https://claude.ai/code/session_01CkBkcRuEtVuENx2eTJF9Gv
<source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg">https://backend.blacksmith.sh/track/enable-autofix?expires=1793556081&installation_model_id=432790&pr_number=1585&ref=codesmith_pr_footer&repository=octanejs%2Foctane&return_to=https%3A%2F%2Fgithub.com%2Foctanejs%2Foctane%2Fpull%2F1585&signature=ba23989284b80252b638600cbca4753a0ad612d0fb061891f77848eeacd6dc1e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg">Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes hydration mismatch-recovery reporting in
runtime.ts; DOM adoption paths are intended to stay the same, but incorrect deduplication could hide real mismatches or over-suppress warnings.Overview
Hydration mismatch recovery no longer emits a separate dev-console diagnostic for every sibling component when one server range is rebuilt. If the server left text (or other content) where the client renders multiple component calls, the first sibling still reports and discards up to the range end; later siblings that land on that same closing marker no longer repeat "the end of the parent block".
The runtime tracks range ends already handled in the existing
HYDRATION_REBUILTset viafirstAtRangeEndandreachedRangeEnd, wired throughrenderUnframed, fragment/single-rootadopt(), andrebuildFragment. Separate mismatched ranges still get their own warnings; matching server markup is unchanged.Adds
component-range-siblingsfixture/tests (dev and prod compile) and lowers expected structural warning counts in the suspended clone mismatch controls from 2 to 1 where a second sibling previously duplicated the report.Reviewed by Cursor Bugbot for commit ee5c990. Bugbot is set up for automated code reviews on this repo. Configure here.