Repository navigation
fix(hydration): adopt the server's node at a renderable hole in a fragment adopted in place - #1613
Merged
Merged
Conversation
…gment adopted in place
A component call with no server range of its own adopts its fragment
template in place of the raw markup the server rendered for another arm or
component. The server frames every renderable hole's value in a range, but
that markup frames none, so a {value} hole's walk found the server's bare
text, or the node after the fragment, where its own placeholder belongs.
childSlot took that server node as the slot's end marker: a text hole
inserted a second copy of the server's text before it, and a {null} hole
that is the fragment's last root made the next server node its end, while
fragmentRemainder counted that node as the fragment's content, so it stayed
on screen without a report.
HydrationCapability.frameHole frames what the server rendered for such a
hole, as the server would have, and the hole adopts that range through the
ordinary path. A hole before another root holds the one node the compiled
walk counts for it. The fragment's last root (recorded by fragmentRemainder
as inPlaceHole) holds its node only when the value renders that kind of
node; otherwise the fragment's server nodes end before it, and what follows
is the stale tail the enclosing claim removes and reports once.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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)
39 other measured values are unchanged. Public-import reachability bundles (bytes)
85 other measured values are unchanged. |
…ts for an open marker The benchmark report showed +13 raw bytes in every bundle with a child slot, including ones that never hydrate (root-static, octane-jsx), from the extra arguments at frameHole's call site. HydrationCapability.holeOpen now replaces the existing isOpen(anchor) test there: it returns the server's open marker, the frame it gives a hole in a template adopted in place, or null, so the branch no longer reassigns the anchor and non-hydrating bundles keep their size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 22:36
This was referenced Oct 3, 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
A component call with no server range of its own adopts its fragment template in place of the raw markup the server rendered for another
@ifarm or component (renderInPlace→adopt()'s in-place fragment branch →fragmentRemainder; prod goes throughrenderUnframed(…, unframed = true)). The server frames every renderable hole's value as<!--[-->…<!--]-->, but that raw markup frames none. A{value}hole's compiled walk therefore found a bare server node where its own placeholder belongs.childSlottook that node as the slot's end marker:<p>p</p><em>e</em>x, client<Para/>+<EmText text="x"/>. EmText is@{ <><em>{'e'}</em>{props.text}</> }. The section read…<em>e</em>xx, in both the dev and prod compiles.{null}hole counted as owning a server node. Server<p>p</p><em>e</em><s class="tail">s</s>, client<Para/>+<EmNull/>.fragmentRemainderstepped one server node for the hole, so<s>was treated as fragment content. It stayed unreported in dev, and prod'srenderUnframedframed it inside the call's<!--comp-->…<!--/comp-->.<em/>{text}<i/>). An element value at the fragment's last root built a fresh element.Changes
HydrationCapability.holeOpen. It replaceschildSlot's existing hydrationisOpen(anchor)test and returns the open marker the hole adopts. That is the server's own marker when it framed the hole. Only inside a template adopted in place (inPlaceEnd !== undefined), it instead wraps what the server rendered for the hole in fresh[/]markers, as the server would have. The hole then adopts that range through the ordinary path:claimRange,discardUnadoptedText, text adoption. Non-hydrating bundles keep their raw size, because the call replaces the oldisOpentest rather than adding a new one.fragmentRemainder(bounded, in-place only) records the server node at a last-root hole asinPlaceHole.renderInPlacesaves and restores it with the other in-place state.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkon the changed files passes.pnpm typecheck: not run repo-wide.pnpm typecheck:filespasses onruntime.ts, the test, and the.tsrxfixture.pnpm test: not run in full; CI covers it.tests/hydration/in-place-fragment-holes.test.ts. It covers dev compile, prod compile, and prod compile with prod runtime, in theoctaneandoctane-prodprojects.childSlotcall, the trailing end correction, the trailing-hole record, and the text and element rules.octane. The rest oftests/hydration(94 files) passes inoctane.benchmarks/bundle-size/run-minimal.mjs:hydrate-rootanddeferred-hydration: +549 B raw / about +157 B gzip.root-static: +0 B raw, +8 B gzip, −28 B brotli. The gzip and brotli changes come from the reshapedchildSlotcondition.context,hooks-state,root-chained-jsxandsuspense-transition: 0.isOpentest.Risk / follow-ups
settleClaimfix). With fix(hydration): discard the server tail after a last call adopted in place #1615's committed head merged in locally (no conflicts), this file and itsin-place-tail.test.tspass together: 120 tests inoctaneandoctane-prod. Until fix(hydration): discard the server tail after a last call adopted in place #1615 lands, CI here fails on exactly the 4 dev-compile tail cases. Merge fix(hydration): discard the server tail after a last call adopted in place #1615 first, then mergemaininto this branch. The two dev-compile tail cases expect the stale<s>after the last call to be removed and reported once with "the client expected the end of the component but the server rendered". That needssettleClaimto settle a tail after a last slot that adopted in place. Without it, those cases fail inoctaneandoctane-prod(4 tests).{null}hole that is the fragment's last root, at the very end of the enclosing server range. It still rebuilds the fragment, as on main. Letting the hole meet the close also routes a component hole there into fix(hydration): adopt a component hole's own server node in a template adopted in place #1602's residual: the lite slot seesanchor === block.endMarker, uses the cursor, and replaces the first adopted root.unframed-fragment-root'sHXcase covers that.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/range adoption in
runtime.ts; wrong framing could cause mismatches or DOM loss, but behavior is covered by new hydration tests.Overview
Fixes hydration when a fragment is adopted in place (
renderInPlace) and the server left renderable holes unframed (raw text/elements instead of<!--[-->…<!--]-->).The runtime adds
holeOpen, used fromchildSlotinstead of only checkingisOpen(anchor). Inside an in-place template it can wrap the server’s bare node in hydration markers so{value}holes reuse that text or element (no duplicate text) and update in place.inPlaceHoleplusfragmentRemaindertrack the server node at a last-root hole so{null}does not treat the following sibling as fragment content—stale tail nodes are removed and reported once.Adds
in-place-fragment-holesfixture/tests (dev/prod compile and runtime) and an octane patch changeset.Reviewed by Cursor Bugbot for commit 609fccc. Bugbot is set up for automated code reviews on this repo. Configure here.