Repository navigation
fix(hydration): park past every boundary, list, and activity range - #1621
Conversation
A @Try never moved the hydration cursor past its own server range, so a following multi-root component in a template-less body found a close marker, built fresh DOM beside its orphaned server copy, and reported a false mismatch even with identical props. JSX <ErrorBoundary> (errorBlock) had the same gap. @for and <Activity> stepped the cursor directly instead of through parkPast, so an @if/@switch arm ending in any of these could not tell where its content ended and kept the server's longer tail on screen unreported. tryBlock (including its initial-suspense path), errorBlock, forBlock, activityBlock, and childSlot now end with parkPast, as component and branch slots already do. That makes #1578's close-marker step in discardArmTail and rebuiltSlot's park-on-close redundant, so both are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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: Park after disposed error boundary
- Added a
!state.parentBlock.disposedguard to theparkPastcall inerrorBlockso that whenmountErrorBoundaryreturns early due to parent disposal, the caller no longer overwrites the hydration cursor an ancestor catch boundary already placed.
- Added a
Or push these changes by commenting:
@cursor push 8dca775895
Preview (8dca775895)
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
@@ -39105,8 +39105,11 @@ export function errorBlock(
}
} else mountErrorBoundary(state, hydration);
// Hydration: park past the boundary's range, as every slot does, so a
- // following sibling adopts its own server content.
- if (!state.passthrough) hydration?.parkPast(state.end, parentScope);
+ // following sibling adopts its own server content. Skip when the parent was
+ // disposed during mount — an ancestor boundary already owns the cursor and
+ // state.end may be detached.
+ if (!state.passthrough && !state.parentBlock.disposed)
+ hydration?.parkPast(state.end, parentScope);
return state.reset;
}
@@ -39105,8 +39105,11 @@ export function errorBlock(
}
} else mountErrorBoundary(state, hydration);
// Hydration: park past the boundary's range, as every slot does, so a
- // following sibling adopts its own server content.
- if (!state.passthrough) hydration?.parkPast(state.end, parentScope);
+ // following sibling adopts its own server content. Skip when the parent was
+ // disposed during mount — an ancestor boundary already owns the cursor and
+ // state.end may be detached.
+ if (!state.passthrough && !state.parentBlock.disposed)
+ hydration?.parkPast(state.end, parentScope);
return state.reset;
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit c3462a9. Configure here.
A boundary whose render disposed its parent (a cleanup error an ancestor boundary caught) still parked past its own, now detached, range, which could overwrite the cursor the ancestor's catch had placed. parkPast now skips a disposed parent, matching componentSlotImpl and childSlot, which already return before parking in that case. The check lives in HydrationCapability, so non-hydrating bundles are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
6 other measured values are unchanged. Public-import reachability bundles (bytes)
72 other measured values are unchanged. |
|
Benchmark report reviewed; no change needed. The size deltas are the expected cost of moving
🤖 Addressed by Claude Code |
# Conflicts: # packages/octane/src/runtime.ts


Summary
Fixes review findings C1-1 (P1) and C1-4 (P2) from the 2026-10-02 sweep. Both come from one cause: some slots did not move the hydration cursor past their own server range.
@trynever parked past its range. In a body with no template, such as<>@try {…}<Pair /></>, the next multi-root component found a close marker, built fresh DOM after its orphaned server copy, and reported a false mismatch even with identical props:<u>ok</u><i>u</i><s>s</s><i>u</i><s>s</s>. A client-thrown@trybehaved the same way. JSX<ErrorBoundary>(errorBlock) had the identical gap, which the review did not list.@forand<Activity>moved the cursor directly instead of throughparkPast, so the enclosing arm never recorded where they ended. An@if/@switcharm ending in a@for,@try(adopted, client-thrown or still loading),<ErrorBoundary>or<Activity>therefore kept the server's longer element or text tail on screen, with no report.Changes
tryBlock,errorBlock,forBlock(both exits),activityBlockandchildSlotnow end withhydration?.parkPast(end, parentScope), as component and branch slots already did.tryBlock's initial-suspense path now reaches the same park instead of returning early.errorBlock's mount path moves intomountErrorBoundary, so the boundary has one exit and one park.discardArmTail;rebuiltSlot's park-on-close. It now always parks past the range, so a catch switched from outsidetryBlockstill leaves a valid cursor.Not included: the review patch's markerless and in-place hunks. Those are C1-2 (owned by another session), C1-3 and C1-5.
Validation
pnpm format:check(scopedpnpm format:files:checkon the changed files: clean)pnpm typecheck(scopedpnpm typecheck:fileson the changed files: only the two existingtryboundary.tsrxerrors, which main's versions show too)pnpm test(not run locally; left to CI)try-hydrate.test.tsandbranch-arm-tail.test.ts, 28 across the dev and prod compiles, all failing on main:@tryor<ErrorBoundary>followed by a multi-root component, with matching props and with a client throw, keeping every server node and reporting nothing;@for,@try,<ErrorBoundary>,<Activity>or a@trystill loading on the client, discarded with one report;@try12,<ErrorBoundary>6,@for4,<Activity>2, initial-suspense path 2.--project octaneand--project octane-prodbefore the rebase onto fix(signals): load the browser's own query selection over a seed for another request #1618:returned-jsx-query-resume.test.ts, whose 6 failures also occur with main's runtime (the existing fix(hydration): key signal owners below returned JSX by authored invocations only #1601 break)._review_C1_tailrepro now fails only cases 8, 9 and 11a/11b, which are C1-3, C1-5 and C1-2.Risk / follow-ups
.tsrxshape I could construct observes thechildSlotpark. A{hole}always gives the arm a<!>template whoseclaimRootsend takes precedence. It is kept so every slot parks the same way, and only the existing suites cover it.@tryadds about 22 B raw and 10 B gzip,@forabout 6 B raw and 7 B gzip;Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core hydration cursor logic across many slot types; behavior is well-covered by new tests but incorrect parking could still cause subtle SSR/client DOM mismatches.
Overview
Fixes hydration cursor drift after
@try,<ErrorBoundary>,@for, and<Activity>by parking past each slot’s server range the same way components and branches already do.Sibling adoption: When a boundary left the cursor inside its own range, a following multi-root sibling (e.g.
<>@try {…}<Pair /></>) could miss its server nodes, duplicate DOM, and raise false mismatches.tryBlockanderrorBlocknow always end withparkPast;errorBlockmount logic is consolidated so every path shares one exit.Branch arm tails:
@for,<Activity>, andchildSlotswitch from manualgetNextSiblingtoparkPast, so@if/@switcharms that end in those slots can discard the server’s extra tail and report once viadiscardArmTail.rebuiltSlotalways steps past the slot end;parkPastno-ops when the parent block was disposed; the old close-marker workaround indiscardArmTailis removed.New hydration fixtures and tests cover pair-after-boundary adoption, list/try/boundary/activity tails, client-thrown boundaries, and pending
@tryarms.Reviewed by Cursor Bugbot for commit 9d8fe11. Bugbot is set up for automated code reviews on this repo. Configure here.