Repository navigation
fix(hydration): keep a later sibling's server range when a component without one is built - #1589
Merged
Merged
Conversation
…without one is built A component call that finds no server range of its own renders between fresh markers, then hydration discards the server nodes in its place. The discard ran until a block close, so it consumed a later sibling call's range open marker and content and stopped at that range's close, which stayed behind as a stray marker. The sibling then rebuilt its server content without a report of its own. The discard now stops at any block marker or client-built node, leaving a later range for the sibling call that claims it. The fresh markers go where the discarded nodes stood (HydrationCapability.unframedBefore) rather than at the parent range's end, so the built component stays ahead of siblings that adopt their server ranges. componentSlot and the anchorless lite path both use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nman-987ab8-oqeans
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Te3NJRzy6R5Vkkc7KuJvys
…nman-987ab8-oqeans # Conflicts: # packages/octane/src/runtime.ts
…nman-987ab8-oqeans
#1561 added a public HydrationCapability.replaces(node) for rebuilt roots. The merge kept both methods, so the later definition overrode the unframed sweep's private replaces(node, anchor). Name the sweep's predicate unframedReplaces. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Te3NJRzy6R5Vkkc7KuJvys
trueadm
marked this pull request as ready for review
October 2, 2026 18:19
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)
32 other measured values are unchanged. Public-import reachability bundles (bytes)
72 other measured values are unchanged. |
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
…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]>
This was referenced Oct 2, 2026
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
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]>
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 no server range for a component call (for example a component that rendered nothing on the server in the arm being hydrated),
componentSlotImplbuilds it fresh andHydrationCapability.renderUnframeddiscards the server nodes left in its place. That discard loop only stopped at the anchor, the fresh start marker, or a block close. It ran straight through a later sibling call's<!--[-->open marker and content, so:<!--]-->close marker was left in the DOM;This change:
HydrationCapability.unframedReplaces(node, anchor): a server node is discarded only if it is ahead of the anchor and is neither a block open, a block close, nor a client-built (fresh) node. A block open belongs to a later sibling, which claims it.unframedBefore(stale, anchor), used by bothcomponentSlotImplandmountUnframedLite, to mint the freshcompmarkers in place of the replaced server nodes, so the component stays ahead of later siblings.Validation
pnpm format:check(scopedpnpm format:files:checkon the changed files instead)pnpm typecheck(scopedpnpm typecheck:fileson runtime.ts, the test and the fixture instead)pnpm test(theoctaneandoctane-prodVitest projects instead; CI runs the rest)packages/octane/tests/hydration/unframed-component-siblings.test.ts, with dev and prod compiles of four shapes (empty component first, empty then a ranged sibling, a pair then a ranged sibling, host-wrapped empty first) plus toggle-off/on updates afterwards. It fails onmainand passes here.componentSlotImplplacement; dropping themountUnframedLiteplacement; dropping the fresh-node stop (red in fix(hydration): rebuild component calls in an adopted element with other server content #1563'sadopted-host-component-clonesibling cases).pnpm staged-dom:check,pnpm sync(no changes).main: all 258 hydration test files pass inoctane+octane-prod(12504 tests).octane+octane-prodVitest projects, at the previous merge ofmain: 37090 passed, 4 failed. The 4 failures arebehavior-root.test.ts > preserves destructured props through getter reentry, abort and recovery(dev/prod × both projects). They fail the same way onmainwithout this change.node benchmarks/bundle-size/run-minimal.mjson this head and onmainat the previous merge, with budget gates passing: +37 raw / +11–18 gzip in the scenarios that pull in the component slot, hydrate-root +116 / +32, deferred-hydration +153 / +51. All other scenarios are unchanged.Risk / follow-ups
discardArmTail), which sweeps the server range that no sibling claims at an arm's end. This change stops this sweep from consuming a range that a sibling does claim.Provenance
agent-authored)🤖 Generated with Claude Code
https://claude.ai/code/session_01Te3NJRzy6R5Vkkc7KuJvys
Generated by Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes hydration DOM surgery and sibling range adoption when server/client component shapes diverge; mistakes could leave stray markers or wrong subtree adoption, though the path is narrow and heavily tested.
Overview
Fixes hydration when a component call has no server range and is rebuilt on the client: discard and marker placement no longer swallow a later sibling’s adopted server range.
HydrationCapabilitygainsunframedReplacessorenderUnframedremoves only placeholder server nodes (not block open/close markers or fresh client nodes), andunframedBeforesocomponentSlotImplandmountUnframedLiteinsert freshcompmarkers in place of those nodes instead of appending at the parent end. Siblings can still adopt their ranges, DOM order stays correct, and hydration markers stay balanced.Adds a changeset plus
unframed-component-siblingsfixture/tests (dev and prod compile) covering empty/multi-root/lite-first shapes and post-hydration toggles.Reviewed by Cursor Bugbot for commit a055d1c. Bugbot is set up for automated code reviews on this repo. Configure here.