Repository navigation
fix(hydration): keep later sibling ranges when a component range is missing - #1584
Merged
Merged
Conversation
…issing When the server rendered other content where a client component call expects its range, renderUnframed swept server nodes until a close marker. The sweep ran through the next sibling component's open marker and content, so that sibling hydrated against the end of its parent and was rebuilt with a second diagnostic. It also ran on suspension, so a component that suspended blanked the server content while pending. The component's fresh markers now go where the server node they replace stood, and the sweep stops at the next marker comment, leaving later siblings' ranges and boundaries for them to adopt. A suspended render keeps its claim instead of reporting and discarding: the attempt that completes reports once and discards then, both on a preserved <Hydrate> resume and on a root retry. rebuildFragment now defers its report and discard to drainFrag, so a use() hole that suspends leaves the server content on screen. Hookless fragment components anchored at their parent's end take the same missing-range path as other components, so dev and prod recover and report alike. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LqA51dmsggKyu7uH3zc9N2
Resolve runtime.ts against #1561, #1567 and #1576: keep main's adopted-range claims (renderClaimed) and in-place lite rendering (renderInPlace) beside the unframed-claim changes. #1567 renders a lite call that found no range against the cursor, so a hookless component that renders nothing leaves the server element to the next call. Drop this branch's routing of such calls through the missing-range path, which contradicted that. Fix the over-sweep where it happens instead: when such a call rebuilds its fragment, placeRebuilt now discards only the server content in its place, up to the next marker, and drainFrag inserts the fragment there, ahead of later siblings' ranges. The development diagnostic names the call site. renderUnframed shares the same bounded sweep (discardInPlace). The fixture's FragChild gets a hook so it is a full component call in both compiles, which is the path that case covers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LqA51dmsggKyu7uH3zc9N2
Resolve runtime.ts against #1589, which also stopped renderUnframed's sweep at a later sibling's range and placed the fresh markers where the replaced server node stood. Keep this branch's discardInPlace, whose sweep stops at every marker and so covers #1589's block open/close stop, and its unframedBefore. Drop #1589's unframedReplaces and its copy of unframedBefore, which nothing calls after the merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 19:08
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
24 other measured values are unchanged. Public-import reachability bundles (bytes)
72 other measured values are unchanged. |
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]>
2 of 5 tasks
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
When hydration finds other server content where a client component call expects its range (for example, the server rendered another
@if/@switcharm), the component is now built where that content stood and only that content is discarded. Later sibling components keep their server ranges and adopt their server nodes, instead of being rebuilt with a second mismatch report.HydrationCapability.renderUnframedused to insert the rebuilt component's markers at the slot's anchor (the end of the enclosing arm) and sweep server nodes until a close marker. That sweep ran through the next sibling's<!--[-->and content, so the sibling hydrated against the end of its parent and was rebuilt. The markers now go in place of the server node (unframedBefore), and the sweep stops at the next marker comment (discardInPlace): a later sibling's range or boundary, or the end of the enclosing range.unframedClaims), so the server content stays on screen. The attempt that completes reports once and discards, both on a preserved<Hydrate>resume (renderSuspendedrenders the suspended leaf without adopting; the slot's re-render completes the claim) and on a root retry.rebuildFragmentdefers its report and discard todrainFrag(placeRebuilt). A fragment rebuilt over another component's range whoseuse()hole suspends now leaves the server content on screen and reports once.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkon the changed files passes.pnpm typecheck: not run repo-wide.pnpm typecheck:filesonruntime.ts, the test, and the.tsrxfixture passes.pnpm test: not run. Theoctaneandoctane-prodVitest projects were run on the merged head (below).packages/octane/tests/hydration/unframed-component-range.test.ts(20 cases across development and production compiles) asserts final DOM, adopted-sibling identity, server content visible while suspended, and exact diagnostics. 17 fail on main's runtime; the 3 that pass are controls. The related hydration suites (32 files, including main's newin-place-component-sibling,adopted-component-tailandrebuilt-clone-*suites) pass in both projects: 1104 tests.octane: 20,407 passed, 12 failed. Fulloctane-prod: 16,980 passed, 14 failed. Every failure is inbehavior-root.test.ts,compiler/volar.test.tsorhydration-ssr-diagnostics.test.ts. Run alone,behavior-rootfails the same 2 "getter reentry" tests on main's runtime and on this branch (likely the local Node 22.22.0, below the required 22.22.2); the others were load timeouts that pass alone.pnpm staged-dom:checkpasses. The CI minimal bundle budget gate passes: 4 scenarios are byte-identical to main andcontextgrows by 189 raw / 76 gzip / 48 brotli bytes.Risk / follow-ups
<Hydrate>, the component's already-rendered client nodes show beside the server content (a preserved activation keeps partial client DOM).<Hydrate>, the server content is lost while pending and the resume throwsNotFoundError.Provenance
agent-authored)https://claude.ai/code/session_01LqA51dmsggKyu7uH3zc9N2
<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=1793555893&installation_model_id=432790&pr_number=1584&ref=codesmith_pr_footer&repository=octanejs%2Foctane&return_to=https%3A%2F%2Fgithub.com%2Foctanejs%2Foctane%2Fpull%2F1584&signature=1407ffd472b8270e5aff70362e4c75edc1fe3eae60dd3820d8850697eaa3d98a"><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
Touches core hydration cursor, discard, and suspense resume paths in
runtime.ts; incorrect bounds could mis-adopt siblings or double-report mismatches, though coverage is broad.Overview
Fixes hydration when the server left other content where a client component call expected its range (e.g. a different
@ifarm). The client now inserts fresh range markers in place of that server node and removes only nodes up to the next block marker (discardInPlace), so later siblings still adopt their server ranges instead of being swept and rebuilt with duplicate mismatch reports.Suspense: unframed renders that throw suspense keep the claim (
unframedClaims) and leave server DOM visible until a completing attempt;<Hydrate>resume usesrenderSuspendedso the leaf retries without adopting early. Fragment recovery defers mismatch reporting/discarding fromrebuildFragmenttoplaceRebuiltindrainFrag, including hookless lite-slot fragments over another component’s range.Adds a patch changeset and
unframed-component-rangehydration tests (dev + prod compile).Reviewed by Cursor Bugbot for commit fdc411a. Bugbot is set up for automated code reviews on this repo. Configure here.