Skip to content

fix(hydration): keep a rebuilt clone where the server node it replaced stood - #1561

Merged
trueadm merged 20 commits into
mainfrom
fix/rebuilt-clone-position
Oct 2, 2026
Merged

trueadm merged 20 commits into
mainfrom
fix/rebuilt-clone-position

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When a component's template root doesn't match the server node at the hydration cursor, HydrationCapability.adopt reports the mismatch, discards that node, and rebuilds the root. commitBag then inserted the rebuilt root before its block's end marker. Several symptoms followed, in dev and prod:

  • Wrong order: a server sibling that a later client sibling adopted ended up before the rebuilt root. For example, <em>e</em><i>ok</i> was rendered instead of <i>ok</i><em>e</em>.
  • Stale tail: server nodes after the rebuilt root that nothing claimed stayed on the page.
  • @switch the server didn't render: it computed its range from the static anchor. It published empty markers after the rebuilt root, and the root stayed on screen after a case change. With a following sibling, the server <em> was left behind as well, a second diagnostic was logged, and a duplicate client <em> was built.
  • Text hole after the rebuilt root: threw NotFoundError.
  • @try resuming after the rebuild: each attempt gets a new capability, so the resume read the misordered DOM as server output. It logged two false mismatches ("expected but the server rendered ", "expected but the server rendered ") and rebuilt the adopted <em>.

This change:

  • Placement: adopt records the server node that followed the discarded one, and commitBag inserts a detached rebuilt root before it (rebuiltPosition). commitBag also no longer moves a fresh root that is already in its block's parent.
  • Stale tail: an adopted @if/@switch arm removes that recorded node and everything after it up to its end, quietly, when nothing claimed it (sweepRebuiltTail). The rebuild already reported this mismatch. An unframed lite component that renders at that node drops the record, so a later sibling that adopts the node is never swept.
  • Unframed single roots: a singleRoot component without a server frame steps the cursor past a root it adopted (stepPastRoot). It also finds a root rebuilt in the cursor's place (freshAfter).
  • Markerless branches: a @switch/@if that hydrates with no server range takes its bounds from the cursor (markerlessCursor/markerlessEnd). finalizeMarkerlessBranch gains a contentEnd separate from the anchor that its root slots use.
  • Suspense resume: since fix(hydration): keep a suspended @try arm's server content when its attempt rebuilt a mismatch #1560, a suspended Suspense attempt rolls back its recovery, so the resume rebuilds the root again. The placement fix puts it where the server node stood, and the adopted sibling is kept. This branch's earlier shared set of client-built nodes was dropped in the merge. The tail sweep calls save(), so its removals roll back too.

None of this touches the happy adoption path. The only addition there is one null check per hydrated arm.

Folded in: keep the mismatched server node until its rebuilt root commits (8d5ccb8)

adopt used to remove a mismatched server node as soon as it built the replacement. If the rebuilt root then suspended before commitBag (a use() after the clone), two things went wrong. The server content vanished while it waited. A deferred <Hydrate split={false}> boundary also retried the same blocks from its preserved cursor, which by then sat on the next sibling's server range, so the retry mismatched that range, reported a second mismatch and rebuilt the sibling. This change:

  • Deferred discard: adopt steps the cursor past the mismatched node without removing it and records it (replaced). rebuiltAt removes it when the rebuilt root commits, before returning the anchor, because a Document holds one element. commitBag keeps the one-optional-call shape from 3c63981. The <Hydrate> wrapper insert uses the same call.
  • Retry: a suspended deferred activation resumes at the pending node (resumeAt). A mismatch at that same node is not reported again.
  • Markerless arm that suspends with its replacement pending: a client marker pair around the node bounds it (delimitMarkerlessBranch, extracted from finalizeMarkerlessBranch). A retry then puts the root there, and a case change removes the node with the arm. Self-marking the node can't work, because the node is removed at commit.
  • Swap into a client-minted pair while hydrating (the MARKER path with a non-isOpen start): builds the new arm as client DOM instead of hydrating it against the client's own close marker.

The happy adoption path is unchanged. Everything new runs only on a mismatch, a suspension, or a hydrating swap.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test: I ran the octane and octane-prod projects instead (results below). CI covers the remaining projects.
  • targeted tests:
    • New tests/hydration/rebuilt-clone-order.test.ts (dev and prod compile). It covers sibling order and adopted identity, the stale tail, a later sibling that adopts the node after the rebuild, a text hole after the rebuilt root, and @switch with and without a sibling, including case changes. It also covers a @try resume with a suspending reader in the rebuilt subtree. It asserts final DOM, adopted-node identity, and exactly one structural diagnostic and recoverable error. All 14 cases fail on the base, and the text-hole case throws NotFoundError.
    • Follow-up for Bugbot (798343c): a @switch arm the server didn't render adopts the server <u> in place, then suspends inside an initial Suspense boundary. The arm used to publish empty markers before the adopted node on the throw, so the resume rebuilt it. It now finalizes on a throw only when it rebuilt a root in the cursor's place. The new case asserts the <u> is adopted across the resume with no diagnostics, and that a case change removes it. It fails on afcdb05, and on main it leaves a duplicate <em>.
    • Unframed root boundary (5036800, from Bugbot): a component with no server frame whose cursor was the enclosing range's closing marker stamped that marker as its boundary. The new HMR case (the server arm lacked the client's Leaf) fails on the previous head, where the hot update was declined. The block now takes a rebuilt root, then one built at its anchor, and an adopted node only otherwise.
    • Deferred retry hardening removed: two later commits (912c268, 78a05eb) made a suspended markerless arm self-mark the element at the cursor, and remounted a swapped arm under suspended hydration. Bugbot showed the self-mark could throw NotFoundError when a retry discarded a node the arm had not adopted, and that text cursors and multi-root arms were still uncovered. 5036800 takes that work back out, so those paths match main again.
    • New tests/hydration/rebuilt-clone-suspended.test.ts (dev and prod compile, 16 cases), for the folded fix. A rebuilt @switch arm resumes in a deferred boundary, an initial @try, and a root attempt. The server node must stay on screen while suspended, the adopted <em> must keep its identity, exactly one structural diagnostic and recoverable error must be reported, and later case changes must work. The suite also covers a case change before the deferred arm resumes, a rebuilt component root, a root rebuilt over another component's range, and a rebuilt <Hydrate> wrapper. On 3c63981, 10 cases fail and the deferred ones report twice and rebuild <em>. I removed each of the 7 parts of the fix separately and each made 2 to 14 cases fail. root-container-contract's document-shell case caught an insert-before-remove ordering in an earlier draft.
    • Folded head 7499b22 (8d5ccb8 merged with main at fdf54fe): the full octane and octane-prod projects passed, 37,101 tests in 1,342 files, with no failures. pnpm sync, format and typecheck of the changed files are clean. The --budgets gate passes: root-chained-jsx is 85,938 raw / 28,504 gzip against 85,952 / 28,512. Against 3c63981, the folded fix measured −1 raw on client-only fixtures, +350 raw / +93 gzip on hydrate-root, and +396 / +113 on deferred-hydration.
    • New case in tests/hmr.test.ts: a hot update to a root rebuilt during hydration ahead of an adopted sibling. It covers the boundary of the rebuilt unframed root, which only HMR can observe.
    • Each part is load-bearing: I reverted each of the 8 parts of the fix separately, and each made at least one test fail.
    • The fresh-host block fix's SeedBranch fixture (fix(hydration): mount blocks inside a rebuilt clone as client content #1552): with fix(hydration): mount blocks inside a rebuilt clone as client content #1552 alone it shows the three diagnostics, two recoverable errors, and the rebuilt <em>. With this change it gets one diagnostic and keeps the original <em>.
    • Full octane and octane-prod projects: 36,503 passed and 44 failed, all timeouts or knock-ons from timeouts, with the machine at load average ~98. The 11 affected files pass in isolation with longer timeouts, except one behavior-root test with its own 15 s limit. That test also times out on base main's runtime under the same load (15.2 s on main versus 15.5 s here). Before the rebase, the full run passed apart from load timeouts in behavior-root and volar, which pass in isolation.

Performance, measured against the pre-rebase base 3ffd8cc with the same commands. The code delta didn't change in the rebase.

  • Bundle size (benchmarks/bundle-size/run-minimal.mjs):

    Scenario raw gzip
    Typical client-only (e.g. root-chained-jsx, re-measured on 3c63981 against current main) +5 under its committed budget
    base-ui / radix +112 ~+50
    hydrate-root +793 +219
    deferred-hydration +905 +301
    suspense-transition +145 +67

    Server, behavior-root, and aria/motion/floating-ui bundles are unchanged. Hydration-only logic lives in HydrationCapability methods, so mainly hydrating apps carry it. An earlier draft called isBlockClose from componentSlotImpl and pulled the marker parser (~1.3 KB) into client bundles; that is fixed.

  • Branch slot work (benchmarks/client-hot-paths/branches.mjs): hydration lookup counts and work guards are identical.

  • Client mount DOM operations (benchmarks/dom-template-mount): all 7 targets are identical, and the semantic controls pass.

  • Hydration timing (benchmarks/hydration-range-compaction): the base (0.797 / 0.829 ms per 100 wrappers) fell between two candidate runs (0.823 / 0.840 and 0.742 / 0.748), so any difference is within noise.

  • Adopted-host markerless arm (e478664, from Bugbot): a markerless arm that adopted its host in place, with a component inside it, left the cursor outside the arm's parent. The range then fell back to the static anchor and took in later server siblings. The arm's content now ends after the host it adopted. New regression keeps a server sibling out of a @switch arm that adopted its host in place; it runs in CI only, since Dominic asked sessions not to run tests locally.

  • Merged with fix(hydration): continue after a component adopted in place without a range #1567 (204479b): fix(hydration): continue after a component adopted in place without a range #1567's renderInPlace steps the cursor past a node that an unframed lite or singleRoot call adopted in place. It replaces this branch's narrower stepPastRoot and lite-path tail clear, which were removed. The singleRoot boundary now stamps the cursor only when the body adopted it or threw, no root was rebuilt in its place, and it is not a closing marker. The fallback still finds a root rebuilt in the cursor's place before probing the anchor. Locally only the light gates ran (scoped typecheck, format, sync); CI covers the tests.

  • Merged with fix(hydration): discard server ranges a shorter @if/@switch arm leaves unclaimed #1564 (9f28db5): after an adopted arm renders, this branch's quiet sweepRebuiltTail runs before fix(hydration): discard server ranges a shorter @if/@switch arm leaves unclaimed #1564's discardArmTail. Server content left after a rebuilt root goes under that root's single report, and discardArmTail still reports any other unclaimed range. rebuilt-clone-blocks' ForeignListBranch now expects one diagnostic instead of two, and both of its foreign tails are asserted removed. Locally, only the affected files ran on the merged head (branch-arm-tail, rebuilt-clone-blocks, rebuilt-clone-order and hmr, 103 tests in each project); CI covers the rest.

Risk / follow-ups

  • Scope of the tail sweep: it covers adopted @if/@switch arms only. A rebuilt root that is the last thing in a component frame, @try body, or @for item still leaves an unclaimed server tail.
  • Fragments: a rebuilt multi-root fragment still drains at its range end.
  • Discard before commit: fixed by the folded 8d5ccb8 (see above) for a rebuilt single root.
  • Deferred same-block retries of an adopted arm: this is still main's behaviour. A markerless @switch arm that adopts the server node in place, with no mismatch, and then suspends inside a deferred <Hydrate split={false}> goes wrong on resume. The switch markers land after the server sibling, and a second <em> is built with one false report. A case change before resolve loses the <u> and rebuilds the <em>. A rebuilt arm is now covered; an adopted one needs a bounds design of its own.
  • renderUnframed on suspension: a component with no server range that suspends sweeps from the stale node into the next sibling's server range, and reports, while it waits. That blanks the region and rebuilds the sibling. It was found while probing this fix, and a separate session is working on it. rebuildFragment also still discards server nodes immediately, even though a fragment's use() holes run before drainFrag.
  • Found while probing, not fixed here (follow-ups suggested):
    • An adopted arm with no rebuild keeps unclaimed trailing server nodes and reports nothing.
    • A lite component inside an adopted host element compares against the host instead of its first child. That logs a false mismatch and keeps stale server children.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

High Risk
Large, intricate changes to core hydration DOM adoption, insertion, and Suspense resume paths; wrong edge-case handling would reorder or duplicate live server markup.

Overview
Fixes hydration mismatch recovery so a client-rebuilt template root replaces the server node at the cursor instead of landing at the block end, and so suspension no longer drops the server DOM early.

On structural mismatch, HydrationCapability now keeps the mismatched server node (replaced), advances the cursor, and tracks a rebuilt tail; commitBag, <Hydrate> inserts, and related paths use rebuiltAt to commit the fresh root in that slot and then remove the server range. Retries resume at the same node via resumeAt without a second mismatch report. Adopted @if / @switch arms call sweepRebuiltTail so unclaimed server siblings after the rebuild are removed under the single existing diagnostic.

Markerless control-flow arms gain cursor-based bounds (markerlessCursor / markerlessEnd, contentEnd in finalizeMarkerlessBranch) so roots rebuilt where the server had no range stay inside the arm. Unframed singleRoot blocks detect roots rebuilt after the cursor (freshAfter) and avoid stamping wrong boundaries.

Adds changesets, hydration fixtures/tests (rebuilt-clone-order, rebuilt-clone-suspended), updates rebuilt-clone-blocks expectations (one report, tail swept quietly), and HMR cases for rebuilt roots beside adopted siblings.

Reviewed by Cursor Bugbot for commit c161d68. Bugbot is set up for automated code reviews on this repo. Configure here.

…d stood

When a component's template root did not match the server node at the
cursor, hydration discarded that node and rebuilt the root, but inserted it
at its range end. Server siblings that later client siblings adopted ended
up before it, unclaimed server content after it stayed on the page, a
@switch the server did not render published empty markers after it, and a
text hole after it threw NotFoundError. A Suspense boundary resuming after
the rebuild read the misordered DOM as server output, reported two false
mismatches, and rebuilt the adopted sibling.

The rebuilt root now goes before the server node that followed the one it
replaced. An adopted @if/@switch arm quietly removes the rest of that server
content when nothing claimed it. Unframed single roots step the cursor past
a root they adopt and find a root rebuilt in the cursor's place. A
markerless branch that hydrates without a server range takes its bounds
from the cursor, and initial Suspense hydration attempts share the set of
client-built nodes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 2, 2026
@trueadm
trueadm marked this pull request as ready for review October 2, 2026 11:45

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/octane/src/runtime.ts Resolved
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 33 value(s) increased
  • 🔴 bundle-reachability: 63 value(s) increased

Compares 2a8b39753 with 5ad67dc21 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 3.61 3.97 +10.0% ±38% ⚪ within noise
octane-tsrx replace 8.86 9.70 +9.5% ±65% ⚪ within noise
octane-tsrx add 3.79 4.19 +10.6% ±40% ⚪ within noise
octane-tsrx update 0.59 0.60 +1.7% ±74% ⚪ within noise
octane-tsrx select 0.23 0.22 −4.3% ±84% ⚪ within noise
octane-tsrx swap 0.48 0.59 +22.9% ±63% ⚪ within noise
octane-tsrx remove 0.45 0.54 +20.0% ±87% ⚪ within noise
octane-tsrx runlots 31.38 32.96 +5.0% ±23% ⚪ within noise
octane-tsrx select_lots 0.27 0.24 −11.1% ±58% ⚪ within noise
octane-tsrx clear 43.07 41.06 −4.7% ±26% ⚪ within noise
octane-jsx run 4.00 3.62 −9.5% ±24% ⚪ within noise
octane-jsx replace 8.27 7.73 −6.5% ±28% ⚪ within noise
octane-jsx add 3.29 3.31 +0.6% ±20% ⚪ within noise
octane-jsx update 0.69 0.56 −18.8% ±42% ⚪ within noise
octane-jsx select 0.41 0.34 −17.1% ±37% ⚪ within noise
octane-jsx swap 0.79 0.66 −16.5% ±59% ⚪ within noise
octane-jsx remove 0.65 0.63 −3.1% ±26% ⚪ within noise
octane-jsx runlots 29.27 30.62 +4.6% ±10% ⚪ within noise
octane-jsx select_lots 2.85 2.54 −10.9% ±31% ⚪ within noise
octane-jsx clear 45.09 43.06 −4.5% ±18% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 126,728 126,733 +5 (+0.0%) 🔴
octane-tsrx js_gzip 41,926 41,933 +7 (+0.0%) 🔴
octane-tsrx js_brotli 36,922 36,926 +4 (+0.0%) 🔴
octane-tsrx app_brotli 2,223 2,226 +3 (+0.1%) 🔴
octane-tsrx fw_raw 119,216 119,221 +5 (+0.0%) 🔴
octane-tsrx fw_gzip 39,363 39,370 +7 (+0.0%) 🔴
octane-tsrx fw_brotli 34,699 34,700 +1 (+0.0%) 🔴
octane-tsrx todo_js_raw 141,193 141,632 +439 (+0.3%) 🔴
octane-tsrx todo_js_gzip 46,626 46,754 +128 (+0.3%) 🔴
octane-tsrx todo_js_brotli 40,833 40,931 +98 (+0.2%) 🔴
octane-tsrx todo_app_brotli 2,123 2,119 −4 (−0.2%) 🟢
octane-tsrx todo_fw_raw 136,083 136,522 +439 (+0.3%) 🔴
octane-tsrx todo_fw_gzip 44,150 44,278 +128 (+0.3%) 🔴
octane-tsrx todo_fw_brotli 38,710 38,812 +102 (+0.3%) 🔴
octane-tsrx chat_js_raw 140,438 140,877 +439 (+0.3%) 🔴
octane-tsrx chat_js_gzip 46,569 46,731 +162 (+0.3%) 🔴
octane-tsrx chat_js_brotli 40,899 40,996 +97 (+0.2%) 🔴
octane-tsrx chat_app_gzip 2,981 2,978 −3 (−0.1%) 🟢
octane-tsrx chat_app_brotli 2,640 2,633 −7 (−0.3%) 🟢
octane-tsrx chat_fw_raw 133,785 134,224 +439 (+0.3%) 🔴
octane-tsrx chat_fw_gzip 43,588 43,753 +165 (+0.4%) 🔴
octane-tsrx chat_fw_brotli 38,259 38,363 +104 (+0.3%) 🔴
octane-tsrx weather_js_raw 176,859 177,447 +588 (+0.3%) 🔴
octane-tsrx weather_js_gzip 57,827 58,013 +186 (+0.3%) 🔴
octane-tsrx weather_js_brotli 50,265 50,370 +105 (+0.2%) 🔴
octane-tsrx weather_app_gzip 9,044 9,045 +1 (+0.0%) 🔴
octane-tsrx weather_app_brotli 7,562 7,582 +20 (+0.3%) 🔴
octane-tsrx weather_fw_raw 150,124 150,712 +588 (+0.4%) 🔴
octane-tsrx weather_fw_gzip 48,783 48,968 +185 (+0.4%) 🔴
octane-tsrx weather_fw_brotli 42,703 42,788 +85 (+0.2%) 🔴
octane-jsx js_raw 225,412 225,636 +224 (+0.1%) 🔴
octane-jsx js_gzip 71,924 72,064 +140 (+0.2%) 🔴
octane-jsx js_brotli 62,373 62,396 +23 (+0.0%) 🔴
octane-jsx app_gzip 2,944 2,943 −1 (−0.0%) 🟢
octane-jsx app_brotli 2,503 2,501 −2 (−0.1%) 🟢
octane-jsx fw_raw 216,945 217,169 +224 (+0.1%) 🔴
octane-jsx fw_gzip 68,980 69,121 +141 (+0.2%) 🔴
octane-jsx fw_brotli 59,870 59,895 +25 (+0.0%) 🔴

7 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 116,420 116,425 +5 (+0.0%) 🔴
cli-spa-starter gzip 39,297 39,304 +7 (+0.0%) 🔴
cli-spa-starter brotli 34,325 34,306 −19 (−0.1%) 🟢
root-static-specialized raw 77,067 77,072 +5 (+0.0%) 🔴
root-static-specialized gzip 25,582 25,589 +7 (+0.0%) 🔴
root-static-specialized brotli 22,778 22,781 +3 (+0.0%) 🔴
root-chained-jsx raw 85,933 85,938 +5 (+0.0%) 🔴
root-chained-jsx gzip 28,494 28,504 +10 (+0.0%) 🔴
root-chained-jsx brotli 25,306 25,309 +3 (+0.0%) 🔴
root-static raw 201,735 201,955 +220 (+0.1%) 🔴
root-static gzip 64,098 64,211 +113 (+0.2%) 🔴
root-static brotli 55,500 55,630 +130 (+0.2%) 🔴
root-static-local raw 77,070 77,075 +5 (+0.0%) 🔴
root-static-local gzip 25,569 25,576 +7 (+0.0%) 🔴
root-static-local brotli 22,843 22,822 −21 (−0.1%) 🟢
hooks-state raw 89,231 89,236 +5 (+0.0%) 🔴
hooks-state gzip 29,639 29,649 +10 (+0.0%) 🔴
hooks-state brotli 26,405 26,378 −27 (−0.1%) 🟢
prop-attributes raw 97,385 97,390 +5 (+0.0%) 🔴
prop-attributes brotli 28,663 28,719 +56 (+0.2%) 🔴
context raw 110,113 110,283 +170 (+0.2%) 🔴
context gzip 36,436 36,508 +72 (+0.2%) 🔴
context brotli 32,240 32,306 +66 (+0.2%) 🔴
hydrate-root raw 162,049 164,475 +2,426 (+1.5%) 🔴
hydrate-root gzip 51,891 52,541 +650 (+1.3%) 🔴
hydrate-root brotli 45,171 45,738 +567 (+1.3%) 🔴
deferred-hydration raw 224,607 227,238 +2,631 (+1.2%) 🔴
deferred-hydration gzip 71,429 72,166 +737 (+1.0%) 🔴
deferred-hydration brotli 61,608 62,224 +616 (+1.0%) 🔴
suspense-transition raw 166,620 166,795 +175 (+0.1%) 🔴
suspense-transition gzip 53,542 53,606 +64 (+0.1%) 🔴
suspense-transition brotli 46,767 46,785 +18 (+0.0%) 🔴
component-owned-effects raw 81,679 81,684 +5 (+0.0%) 🔴
component-owned-effects gzip 26,938 26,945 +7 (+0.0%) 🔴
component-owned-effects brotli 24,019 24,023 +4 (+0.0%) 🔴
binding-hooks raw 87,744 87,749 +5 (+0.0%) 🔴
binding-hooks gzip 29,352 29,360 +8 (+0.0%) 🔴
binding-hooks brotli 26,098 26,153 +55 (+0.2%) 🔴
binding-base-ui-vite raw 211,929 212,145 +216 (+0.1%) 🔴
binding-base-ui-vite gzip 67,683 67,819 +136 (+0.2%) 🔴
binding-base-ui-vite brotli 58,612 58,685 +73 (+0.1%) 🔴
binding-base-ui-esbuild raw 209,903 210,114 +211 (+0.1%) 🔴
binding-base-ui-esbuild gzip 67,624 67,748 +124 (+0.2%) 🔴
binding-base-ui-esbuild brotli 58,707 58,764 +57 (+0.1%) 🔴
binding-radix-vite raw 213,858 214,075 +217 (+0.1%) 🔴
binding-radix-vite gzip 68,245 68,343 +98 (+0.1%) 🔴
binding-radix-vite brotli 59,293 59,287 −6 (−0.0%) 🟢
binding-radix-esbuild raw 211,791 212,003 +212 (+0.1%) 🔴
binding-radix-esbuild gzip 68,206 68,353 +147 (+0.2%) 🔴
binding-radix-esbuild brotli 59,116 59,217 +101 (+0.2%) 🔴
binding-mantine-hooks-vite raw 98,020 98,025 +5 (+0.0%) 🔴
binding-mantine-hooks-vite gzip 32,587 32,594 +7 (+0.0%) 🔴
binding-mantine-hooks-vite brotli 28,886 28,959 +73 (+0.3%) 🔴
binding-mantine-hooks-esbuild raw 97,610 97,615 +5 (+0.0%) 🔴
binding-mantine-hooks-esbuild gzip 32,765 32,770 +5 (+0.0%) 🔴
binding-mantine-hooks-esbuild brotli 29,062 29,066 +4 (+0.0%) 🔴
binding-apollo-client-vite raw 356,980 357,197 +217 (+0.1%) 🔴
binding-apollo-client-vite gzip 111,795 111,906 +111 (+0.1%) 🔴
binding-apollo-client-vite brotli 97,503 97,599 +96 (+0.1%) 🔴
binding-apollo-client-esbuild raw 359,959 360,153 +194 (+0.1%) 🔴
binding-apollo-client-esbuild gzip 114,014 114,110 +96 (+0.1%) 🔴
binding-apollo-client-esbuild brotli 99,308 99,359 +51 (+0.1%) 🔴
binding-usehooks-ts-vite raw 98,653 98,658 +5 (+0.0%) 🔴
binding-usehooks-ts-vite gzip 32,737 32,745 +8 (+0.0%) 🔴
binding-usehooks-ts-vite brotli 29,073 29,089 +16 (+0.1%) 🔴
binding-usehooks-ts-esbuild raw 98,232 98,237 +5 (+0.0%) 🔴
binding-usehooks-ts-esbuild gzip 32,912 32,921 +9 (+0.0%) 🔴
binding-usehooks-ts-esbuild brotli 29,268 29,220 −48 (−0.2%) 🟢

37 other measured values are unchanged.

trueadm and others added 3 commits October 2, 2026 13:01
…kerless arm throws

A hydrating @switch/@if arm with no server range that adopted the server
node at the cursor and then suspended published an empty marker pair before
that node. The boundary's next attempt then read those markers as server
output and rebuilt the node instead of adopting it. Such an arm now
finalizes on a throw only when it rebuilt a root in the cursor's place, and
otherwise leaves the DOM as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ition

Keep both sides in renderInitialSuspenseHydration: the attempt's capability
is speculative (#1544) and shares the set of client-built nodes across
attempts. Adapt the rebuilt-tail sweep to main's root hydration journal:
save() the parent before removing the tail, and sweep only while the
rebuilt root still stands right before it, so a rolled-back attempt's
stale tail is never swept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/octane/src/runtime.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Markerless retry keeps stale bounds
    • Changed state.markerlessBefore = before to state.markerlessBefore = contentBefore so that same-branch retry and branch-change abort paths use the cursor-adjusted content start instead of the static positional anchor.

Create PR

Or push these changes by commenting:

@cursor push 631049b2aa
Preview (631049b2aa)
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
@@ -41897,7 +41897,7 @@
 				env,
 			);
 			state.block = b;
-			state.markerlessBefore = before;
+			state.markerlessBefore = contentBefore;
 			try {
 				renderBlock(b);
 			} catch (error) {

You can send follow-ups to the cloud agent here.

Comment thread packages/octane/src/runtime.ts Resolved
…opted

A deferred boundary retries a suspended activation through the same
blocks. A hydrating @switch/@if arm with no server range that adopted the
server node at the cursor, then suspended, was finalized on that retry from
its static anchors. It published empty markers after the server siblings
that later client siblings adopt. The next sibling then rebuilt its root and
logged a false mismatch, and a later case change left the adopted node on
the page. On such a throw the arm now records the cursor's bounds for a
same-block retry, and leaves the DOM unchanged for a new attempt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…opted

A hydrating @switch/@if arm with no server range that suspended with the
cursor still on its element recorded that element's next sibling, a node a
later sibling owns, as its end. A deferred boundary's retry could discard
that node first, so finalizing the arm threw NotFoundError. The arm now
self-marks the element instead. That adds no DOM, so a new attempt still
adopts the element, while a same-block retry or a branch change finds the
arm in place.

A markerless slot that swaps branches while hydrating, such as a case
change before a deferred boundary activates, now mounts the new branch as
client DOM and moves the cursor past the old one. Before this, the next
sibling adopted from a removed node and was rebuilt with a false
mismatch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
trueadm and others added 2 commits October 2, 2026 14:27
…ition

#1560 rolls back a speculative Suspense attempt's structural recovery, so a
suspended attempt's rebuilt root no longer survives into the next attempt.
Take main's InitialSuspenseHydration.stale, and drop this branch's set of
client-built nodes shared across attempts, which is now unused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for all 3 issues found in the latest run.

  • ✅ Fixed: Unframed root stamps leftover cursor
    • Added !isBlockClose(hydrationCursor) guard so that when clone() returns a fresh root without removing a close marker cursor, the finally block falls through to the freshAfter branch that correctly detects the rebuilt root.
  • ✅ Fixed: Self-mark remount can throw NotFoundError
    • Added a parentNode check in rebuiltPosition so that when endMarker has been detached by discardCursor during a retry, the method returns null instead of the dangling reference, preventing NotFoundError in insertBefore.
  • ✅ Fixed: Abort start uses the wrong sibling
    • Changed state.markerlessBefore = before to state.markerlessBefore = contentBefore so the abort sweep starts from the cursor's previousSibling (where content actually begins) instead of after's previousSibling, ensuring adopted prefixes are covered.

Create PR

Or push these changes by commenting:

@cursor push 5bdf044701
Preview (5bdf044701)
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
@@ -19896,9 +19896,9 @@
 	 */
 	rebuiltPosition(root: Node, parent: Node, end: Node | null): Node | null {
 		const next = this.rebuiltTail;
-		return root === this.rebuiltRoot && next !== null && domNode(next).parentNode === parent
-			? next
-			: end;
+		if (root === this.rebuiltRoot && next !== null && domNode(next).parentNode === parent)
+			return next;
+		return end !== null && (STAGED_DOM?.view(end) ?? end).parentNode !== parent ? null : end;
 	}
 
 	/**
@@ -31768,7 +31768,8 @@
 				if (
 					hydration !== null &&
 					hydrationCursor !== null &&
-					(STAGED_DOM?.view(hydrationCursor) ?? hydrationCursor).parentNode === domParent
+					(STAGED_DOM?.view(hydrationCursor) ?? hydrationCursor).parentNode === domParent &&
+					!isBlockClose(hydrationCursor)
 				) {
 					// An unframed single-root return adopts the element that was already
 					// present, so the client-mount before/after probe cannot observe an
@@ -41953,7 +41954,7 @@
 				env,
 			);
 			state.block = b;
-			state.markerlessBefore = before;
+			state.markerlessBefore = contentBefore;
 			try {
 				if (replacing) hydration!.suspend(() => renderBlock(b));
 				else renderBlock(b);

You can send follow-ups to the cloud agent here.

Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
trueadm and others added 3 commits October 2, 2026 14:49
… marker

A component with no server frame whose cursor was the enclosing range's
closing marker, such as a client sibling the server range lacked, stamped
that marker as its own boundary. The root built at the range's end was not
the boundary, so an HMR handoff declined the update. The block now takes a
root rebuilt in the cursor's place first, then one built at its anchor, and
a node it adopted in place only otherwise, never a closing marker.

Remove this branch's deferred same-block retry handling for a markerless
arm. The arm self-marked the element at the cursor when it suspended, and
a markerless swap mounted under suspended hydration. Self-marking a node
the arm had not adopted could throw NotFoundError when a retry discarded
it. Text cursors and arms with more than one root still fell back to
static bounds. Those paths return to main's behavior, which a follow-up
addresses as a whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The signal-free root-chained-jsx bundle went 11 raw bytes over its
committed budget, all of it from commitBag's ternary around
rebuiltPosition. rebuiltAt returns undefined unless a rebuilt root has a
recorded position, so commitBag inserts at
`hydration?.rebuiltAt(root, parent) ?? block.endMarker`, 5 raw bytes over
main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm and others added 2 commits October 2, 2026 16:04
…ition

Keep both sweeps after an adopted @if/@switch arm renders. This branch's
sweepRebuiltTail runs first: the server content a rebuilt root left after
it is the rest of what that root's mismatch replaced, and it goes quietly
under that one report. #1564's discardArmTail then reports any other
server range the arm left unclaimed. rebuilt-clone-blocks'
ForeignListBranch therefore expects one diagnostic, not two, and both
foreign tails are now asserted removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Lite adopt leaves hydration cursor parked
    • Added a rebuiltOpen variable to track the adopted server node in the rebuiltTail branch, then advance the hydration cursor past it after the body renders when clone() left it parked there, mirroring componentSlotImpl's stepPastRoot advance for full unframed single-root components.

Create PR

Or push these changes by commenting:

@cursor push 0e5adf7600
Preview (0e5adf7600)
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
@@ -11660,6 +11660,9 @@
 	// The server node an anchorless call found where its range belonged (first
 	// hydration render only); undefined when it claimed a range or none.
 	let unframed: Node | null | undefined;
+	// The unframed server node a rebuilt root left at the cursor (first
+	// hydration render only) — consumed by the post-body cursor advance.
+	let rebuiltOpen: Node | null = null;
 	if (scope === undefined) {
 		scope = new ScopeImpl(parentScope, parentScope.block);
 		// Lite scope's `block` exposes the host/anchor as the body's DOM context
@@ -11704,6 +11707,7 @@
 			} else if (open === hydration.rebuiltTail) {
 				// The body may adopt this unframed server node as its root.
 				hydration.rebuiltTail = null;
+				rebuiltOpen = open;
 			}
 		}
 		scope.block = new LiteBlockImpl(host, endMarker, parentScope.block) as unknown as Block;
@@ -11775,6 +11779,8 @@
 	// its commitBag insert MOVES the previous sibling's root to the shared
 	// anchor. Mirrors componentSlot's post-render advance.
 	if (hydration !== null && adoptedClose !== null) hydration.node = getNextSibling(adoptedClose);
+	else if (hydration !== null && rebuiltOpen !== null && hydration.node === rebuiltOpen)
+		hydration.node = getNextSibling(rebuiltOpen);
 }
 
 // An anchorless lite call whose server range is missing: render it between

You can send follow-ups to the cloud agent here.

Comment thread packages/octane/src/runtime.ts Resolved
trueadm and others added 3 commits October 2, 2026 16:31
…commits

When a template root did not match the server node at the cursor, adopt()
removed that node as soon as it built the replacement. If the replacement
suspended before commitBag, the server content vanished while it waited,
and a deferred <Hydrate split={false}> boundary retried the arm from the
next server sibling. The retry mismatched that sibling's range, reported a
second mismatch and rebuilt it.

adopt() now steps past the mismatched node and records it; rebuiltAt
removes it when the rebuilt root commits, before inserting the root in its
place (a Document holds one element). A suspended deferred activation
resumes at the pending node (resumeAt), and a retry over it is not reported
again. A markerless arm that throws with its replacement pending is bounded
by a client marker pair around the node, so a retry puts its root there
and a case change removes the node with the arm; while hydrating, a swap
into a client-minted pair builds the new arm as client DOM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ition

#1567's renderInPlace steps the cursor past a node that an unframed
component adopted in place, in both the lite and the singleRoot paths. It
supersedes this branch's stepPastRoot and its lite-path rebuiltTail clear:
an adopted node no longer leaves the cursor on the rebuilt tail, so the
sweep cannot take it. The singleRoot boundary stamps the cursor only when
the body adopted it or threw (#1567), no root was rebuilt in its place, and
it is not a closing marker. The fallback still finds a root rebuilt in the
cursor's place before probing the anchor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
trueadm and others added 2 commits October 2, 2026 16:52
A hydrating @switch/@if arm with no server range of its own can adopt the
server element at the cursor in place. A component inside that element
leaves the cursor in it, or past its last child. markerlessEnd then fell
back to the slot's static anchor, so the arm's range took in the server
siblings after it, and a case change removed their DOM. When the cursor is
not left in the arm's parent, the content now ends after the element it
started at, while that element is still there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ition

# Conflicts:
#	packages/octane/src/runtime.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Suspended rebuild stamps a doomed boundary
    • In commitBag, after rebuiltAt removes the server node that was stamped as the block boundary, the block markers are now updated to point to the committed rebuilt root so subsequent unmounts and swaps correctly find the live DOM.

Create PR

Or push these changes by commenting:

@cursor push eede0ad94c
Preview (eede0ad94c)
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
@@ -20892,10 +20892,20 @@
 		// which stays until now.
 		if (hydration === null || (STAGED_DOM?.view(root) ?? root).parentNode !== block.parentNode) {
 			const parent = block.parentNode;
-			(STAGED_DOM?.view(parent) ?? parent).insertBefore(
-				root,
-				hydration?.rebuiltAt(root, parent) ?? block.endMarker,
-			);
+			const at = hydration?.rebuiltAt(root, parent);
+			(STAGED_DOM?.view(parent) ?? parent).insertBefore(root, at ?? block.endMarker);
+			// rebuiltAt removed the server node the block stamped as its boundary
+			// (an unframed singleRoot that suspended before this commit). Update
+			// the markers to the root that replaced it so a later unmount or swap
+			// finds the live node.
+			if (
+				at !== undefined &&
+				block.startMarker != null &&
+				(STAGED_DOM?.view(block.startMarker) ?? block.startMarker).parentNode === null
+			) {
+				block.startMarker = root;
+				block.endMarker = root;
+			}
 		}
 	}
 	scope.slots[0] = bag;

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 9ba872a. Configure here.

Comment thread packages/octane/src/runtime.ts Resolved
…undary

An unframed singleRoot whose body rebuilt over the server node at the
cursor and then suspended before its root committed stamped that node as
its block boundary. The server node stays in place until the rebuilt root
commits, and that commit removes it, which left the block's markers
detached for a later identity change, return-shape switch or HMR remount.
The probe now skips a node a not-yet-committed rebuilt root replaces, as
the markerless arm already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Retry skips rebuilt tail sweep
    • Added sweepRebuiltTail call after renderBlock in the same-branch retry path so unclaimed server nodes after a rebuilt root are removed when the retry completes.
  • ✅ Fixed: Markerless end overclaims siblings
    • Wrapped the markerless branch render in renderInPlace when a cursor exists, which steps the hydration cursor past the adopted root after successful adoption so markerlessEnd sees the correct parent-level position.

Create PR

Or push these changes by commenting:

@cursor push 820abeba7e
Preview (820abeba7e)
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
@@ -42306,7 +42306,8 @@
 			state.block = b;
 			state.markerlessBefore = before;
 			try {
-				renderBlock(b);
+				if (cursor !== null) hydration!.renderInPlace(renderBlock, b, cursor);
+				else renderBlock(b);
 			} catch (error) {
 				// A branch that throws before inserting anything stays unfinalized so
 				// a same-branch retry finalizes it. One that already inserted its
@@ -42392,6 +42393,8 @@
 		state.block.body = body!;
 		state.block.extra = env;
 		renderBlock(state.block);
+		if (hydration !== null && hydration.rebuiltTail !== null)
+			hydration.sweepRebuiltTail(state.block.endMarker);
 		const markerlessBefore = state.markerlessBefore;
 		if (markerlessBefore !== undefined) {
 			finalizeMarkerlessBranch(

You can send follow-ups to the cloud agent here.

@trueadm
trueadm merged commit 02e4eb0 into main Oct 2, 2026
31 checks passed
@trueadm
trueadm deleted the fix/rebuilt-clone-position branch October 2, 2026 17:03
trueadm added a commit that referenced this pull request Oct 2, 2026
…without one is built (#1589)

* fix(hydration): keep a later sibling's server range when a component 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]>

* docs(octane): rewrap the renderUnframed comment

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Te3NJRzy6R5Vkkc7KuJvys

* fix(hydration): rename the unframed sweep predicate after merging main

#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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm pushed a commit that referenced this pull request Oct 2, 2026
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
trueadm added a commit that referenced this pull request Oct 2, 2026
…ement in place (#1594)

* test(hydration): cover a full component slot rebuilt over a server element in place

A single-root call that renders through the full component slot (a hooked
component, or in a production compile a call whose output reads only
constants) and finds no server range of its own renders its template against
the server element at the cursor. Before #1561, a mismatch there discarded
that element while it was still the block's insert anchor, so commitBag threw
NotFoundError and hydrateRoot left the container blank.

Pin the recovered behavior in development compile, production compile, and
production compile and runtime: the root is rebuilt in the server element's
place, its server siblings stay adopted, the mismatch is reported once, and
the arm unmounts, remounts and unmounts cleanly afterwards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(hydration): run the constant-output in-place rebuild in a development compile too

#1593 discards a mismatched node inside a lite component's host, so the
development compile's lite call over the server `<u>` now rebuilds in place
like the full component slot does. Cover it in all three modes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(hydration): say the lite slot's in-place rebuild is covered too

The constant-output case's note read as if a development compile were left
out. It runs in all three modes since #1593: say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant