Skip to content

fix(octane): adopt the server catch arm when a template-less use() reader rejected - #1523

Merged
trueadm merged 2 commits into
mainfrom
claude/exciting-dhawan-f00dc7
Oct 2, 2026
Merged

trueadm merged 2 commits into
mainfrom
claude/exciting-dhawan-f00dc7

Conversation

@trueadm

@trueadm trueadm commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hydrating a @try whose body is a template-less component (no @{}, lowered to componentSlot) that use()s a promise the server rejected lost the server's @catch arm:

  • the final DOM had empty comp markers where <p class="caught"> was;
  • onCaughtError never fired;
  • onRecoverableError reported error 55, and dev logged "expected a component range but the server rendered <p>";
  • the root stayed suspended on the client promise.

A template reader (componentSlotLite) in the same position already adopted the server's <p> and reported the caught error. This PR makes the template-less path match it.

Root cause. When the server range was missing, componentSlotImpl acted before the body ran: it reported 55, removed the server nodes (the catch arm), and inserted fresh markers. renderBlock switches hydration off for a dynamic block with a fresh end marker, so use() never read the rejection seed and suspended instead of throwing the rejection the boundary adopts.

Fix (packages/octane/src/runtime.ts):

  • Deferred claim. With no server range, the claim now only records the server node and inserts the fresh markers. The new HydrationCapability.renderUnframed renders the body.
  • Seeds still read. That body adopts nothing, but its use() calls still consume positional seeds, as the server's render did (replayDepth, consumesSeeds(), and seedHydration() at the three seed-read sites: useThenable, seedOrCreate, useBatch).
  • Seeded rejection. Only the fresh markers are removed and the cursor is restored, so mountTry / errorBlock adopt the untouched server catch arm.
  • Any other outcome (renders, suspends, throws an ordinary error). The mismatch is reported (55 plus the dev warning) and the server nodes are discarded, as before, now after the body instead of before it.
  • Decoded reason. switchToCatchInner and switchErrorToCatchInner unwrap a hydration rejection through currentHydration. A @catch arm or <ErrorBoundary> inside that client-built subtree therefore receives the decoded reason, not the internal wrapper.

Validation

  • pnpm format:check: not run repo-wide; pnpm format:files:check on every changed file passes
  • pnpm typecheck: not run repo-wide; pnpm typecheck:files on every changed file passes
  • pnpm test: not run in full; the octane and octane-prod vitest projects pass in full (see below)
  • targeted tests: packages/octane/tests/hydration/try-templateless-reader.test.ts in octane and octane-prod

New regression suite, 9 tests per project:

  • the reader as the sole try child;
  • a boundary with a @pending arm;
  • a reader rendered by another template-less component;
  • a later boundary's seed staying aligned after the caught one;
  • a nested @catch and a nested <ErrorBoundary> getting the decoded reason;
  • three controls: the template reader, a server-resolved reader, and a genuine mismatch that must still report.

Without the fix, 5 of the 8 tests that existed then fail in both projects; the 3 controls pass. Breaking each part of the fix separately also turns a test red:

  • seed reading → 6 fail;
  • either unwrap site → inner:[object Object];
  • the discard loop's stop at the fresh marker → the genuine-mismatch control loses the client output.

Full vitest projects on the rebased head: octane 19,582 passed (683 files) and octane-prod 16,141 passed (608 files). pnpm sync leaves the tree clean.

Bundle size (benchmarks/bundle-size/run-minimal.mjs, base vs candidate, gzip):

  • client-only bundles shrink because the inline report moved into the tree-shakable hydration class: root-static −482, context −176, suspense-transition −167, base-ui/radix/apollo −495 to −531;
  • hydrating bundles grow: hydrate-root +171, deferred-hydration +79.

Risk / follow-ups

  • Seed reads on a genuine mismatch. A component that renders where the server rendered a different tree now consumes positional seeds, as template readers already did. It can take a seed that belongs to a later boundary. Before, it read none, which instead misaligned seeds whenever the server read a value and then threw.
  • Report ordering. The mismatch report now comes after the body, so a nested report published during the body precedes it.
  • Not covered. A template that clones and then throws still reports its clone mismatch. That is a separate defect.

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

Medium Risk
Touches core hydration, use() seeding, and @try/@catch adoption paths; genuine server/client shape mismatches now consume seeds before reporting, which can affect ordering of recoverable errors.

Overview
Fixes hydration when a template-less component’s use() rejected on the server and the boundary rendered @catch where the client expected a component range. Previously the slot claim removed the server catch DOM and reported error 55 before the body ran, so use() never consumed the rejection seed, the tree stayed suspended, and onCaughtError did not fire.

The claim now defers cleanup and runs the body via HydrationCapability.renderUnframed, while seedHydration() / replayDepth let that pass still consume positional seeds (including the rejection) even when it adopts no server nodes. On a seeded rejection, only fresh markers are dropped and the server catch arm is adopted; other outcomes still report the mismatch after the body. Catch / error-boundary paths unwrap hydration rejections via currentHydration so nested handlers get the decoded reason.

Adds a hydration regression suite (try-templateless-reader) covering adoption, seed alignment, nested rethrows, resolved readers, and genuine branch mismatches.

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

…ader rejected

A template-less component (lowered to componentSlot) whose use() rejected
on the server has no server range: the boundary that caught the rejection
rendered its @catch arm in that place. The missing-range claim discarded
that arm, reported a hydration mismatch, and minted fresh markers before
the body ran. The fresh range suspended hydration for the whole body, so
use() never read the rejection seed and the root stayed suspended.

The claim now only records the server node and mints the markers.
HydrationCapability.renderUnframed renders the body without adopting
anything while it still consumes positional seeds. A seeded rejection
removes only the fresh markers, so the boundary adopts the server catch
arm. Any other outcome reports the mismatch and discards the server
nodes as before. Catch arms unwrap a hydration rejection through the
current hydration, so a boundary inside that replay sees the decoded
reason.

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 1, 2026
@github-actions
github-actions Bot marked this pull request as draft October 1, 2026 23:16
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 1 value(s) increased
  • 🔴 bundle-reachability: 6 value(s) increased

Compares f647ceff6 with 6362e8325 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 moving the same way. 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 6.83 4.86 −28.8% ±100% ⚪ within noise
octane-tsrx replace 13.04 10.91 −16.3% ±73% ⚪ within noise
octane-tsrx add 4.92 5.75 +16.9% ±93% ⚪ within noise
octane-tsrx update 0.52 0.55 +5.8% ±100% ⚪ within noise
octane-tsrx select 0.22 0.20 −9.1% ±81% ⚪ within noise
octane-tsrx swap 0.48 0.49 +2.1% ±74% ⚪ within noise
octane-tsrx remove 0.40 0.47 +17.5% ±70% ⚪ within noise
octane-tsrx runlots 35.17 39.06 +11.1% ±25% ⚪ within noise
octane-tsrx select_lots 0.21 0.19 −9.5% ±101% ⚪ within noise
octane-tsrx clear 38.46 39.52 +2.8% ±45% ⚪ within noise
octane-jsx run 8.73 7.23 −17.2% ±84% ⚪ within noise
octane-jsx replace 10.98 12.65 +15.2% ±77% ⚪ within noise
octane-jsx add 4.80 6.64 +38.3% ±98% ⚪ within noise
octane-jsx update 0.93 0.94 +1.1% ±71% ⚪ within noise
octane-jsx select 0.67 0.55 −17.9% ±88% ⚪ within noise
octane-jsx swap 0.94 0.98 +4.3% ±75% ⚪ within noise
octane-jsx remove 0.70 0.82 +17.1% ±67% ⚪ within noise
octane-jsx runlots 48.92 38.16 −22.0% ±68% ⚪ within noise
octane-jsx select_lots 4.54 3.39 −25.3% ±93% ⚪ within noise
octane-jsx clear 43.75 38.48 −12.0% ±48% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx weather_js_raw 175,649 175,076 −573 (−0.3%) 🟢
octane-tsrx weather_js_gzip 57,291 57,099 −192 (−0.3%) 🟢
octane-tsrx weather_js_brotli 49,861 49,620 −241 (−0.5%) 🟢
octane-tsrx weather_app_brotli 7,604 7,566 −38 (−0.5%) 🟢
octane-tsrx weather_fw_raw 148,914 148,341 −573 (−0.4%) 🟢
octane-tsrx weather_fw_gzip 48,247 48,055 −192 (−0.4%) 🟢
octane-tsrx weather_fw_brotli 42,257 42,054 −203 (−0.5%) 🟢
octane-jsx js_raw 225,527 224,213 −1,314 (−0.6%) 🟢
octane-jsx js_gzip 71,867 71,371 −496 (−0.7%) 🟢
octane-jsx js_brotli 62,187 61,860 −327 (−0.5%) 🟢
octane-jsx app_gzip 2,945 2,944 −1 (−0.0%) 🟢
octane-jsx app_brotli 2,502 2,505 +3 (+0.1%) 🔴
octane-jsx fw_raw 217,060 215,746 −1,314 (−0.6%) 🟢
octane-jsx fw_gzip 68,922 68,427 −495 (−0.7%) 🟢
octane-jsx fw_brotli 59,685 59,355 −330 (−0.6%) 🟢

30 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
root-static raw 201,852 200,536 −1,316 (−0.7%) 🟢
root-static gzip 64,046 63,564 −482 (−0.8%) 🟢
root-static brotli 55,549 55,124 −425 (−0.8%) 🟢
context raw 109,932 109,357 −575 (−0.5%) 🟢
context gzip 36,302 36,126 −176 (−0.5%) 🟢
context brotli 32,063 31,898 −165 (−0.5%) 🟢
hydrate-root raw 155,342 155,887 +545 (+0.4%) 🔴
hydrate-root gzip 49,745 49,916 +171 (+0.3%) 🔴
hydrate-root brotli 43,374 43,507 +133 (+0.3%) 🔴
deferred-hydration raw 217,607 217,941 +334 (+0.2%) 🔴
deferred-hydration gzip 69,239 69,309 +70 (+0.1%) 🔴
deferred-hydration brotli 59,791 59,901 +110 (+0.2%) 🔴
suspense-transition raw 165,676 165,166 −510 (−0.3%) 🟢
suspense-transition gzip 53,142 52,975 −167 (−0.3%) 🟢
suspense-transition brotli 46,372 46,273 −99 (−0.2%) 🟢
binding-base-ui-vite raw 212,046 210,730 −1,316 (−0.6%) 🟢
binding-base-ui-vite gzip 67,638 67,107 −531 (−0.8%) 🟢
binding-base-ui-vite brotli 58,643 58,251 −392 (−0.7%) 🟢
binding-base-ui-esbuild raw 210,030 208,715 −1,315 (−0.6%) 🟢
binding-base-ui-esbuild gzip 67,598 67,082 −516 (−0.8%) 🟢
binding-base-ui-esbuild brotli 58,661 58,234 −427 (−0.7%) 🟢
binding-radix-vite raw 213,975 212,659 −1,316 (−0.6%) 🟢
binding-radix-vite gzip 68,182 67,684 −498 (−0.7%) 🟢
binding-radix-vite brotli 59,105 58,706 −399 (−0.7%) 🟢
binding-radix-esbuild raw 211,918 210,603 −1,315 (−0.6%) 🟢
binding-radix-esbuild gzip 68,179 67,661 −518 (−0.8%) 🟢
binding-radix-esbuild brotli 59,252 58,735 −517 (−0.9%) 🟢
binding-apollo-client-vite raw 357,091 355,779 −1,312 (−0.4%) 🟢
binding-apollo-client-vite gzip 111,710 111,215 −495 (−0.4%) 🟢
binding-apollo-client-vite brotli 97,562 97,032 −530 (−0.5%) 🟢
binding-apollo-client-esbuild raw 360,082 358,768 −1,314 (−0.4%) 🟢
binding-apollo-client-esbuild gzip 113,968 113,451 −517 (−0.5%) 🟢
binding-apollo-client-esbuild brotli 99,414 98,827 −587 (−0.6%) 🟢

72 other measured values are unchanged.

CI job durations

  • 🟢 5 job(s) faster than every recent main run: example apps (3/3), validate publishable packages, typecheck checks, React parity shard (2/4), heavy integration (browser - chromium)

Compares the CI run for 61279b261 (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s.

job main median main range this PR Δ
wall clock (first job start to last job end) 17m 36s 13m 51s–23m 15s 15m 19s −2m 17s (−13%) ⚪ within noise
total job time 178m 49s 157m 01s–242m 49s 157m 20s −21m 29s (−12%) ⚪ within noise
example apps (3/3) 4m 19s 3m 41s–6m 06s 3m 34s −45s (−17%) 🟢 faster
validate publishable packages 5m 03s 4m 32s–5m 22s 4m 13s −50s (−17%) 🟢 faster
typecheck checks 10m 02s 8m 33s–11m 07s 8m 25s −1m 37s (−16%) 🟢 faster
React parity shard (2/4) 11m 47s 10m 32s–19m 40s 9m 43s −2m 04s (−18%) 🟢 faster
heavy integration (browser - chromium) 16m 56s 12m 15s–19m 08s 12m 12s −4m 44s (−28%) 🟢 faster
All 26 timed jobs
job main median main range this PR Δ
test shard (Node 24, 1/4) 13m 16s 10m 39s–17m 32s 14m 46s +1m 30s (+11%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 6m 35s 5m 30s–16m 52s 6m 41s +6s (+2%) ⚪ within noise
examples 4s 4s–4s 5s +1s (+25%) ⚪ within noise
test (24) 4s 4s–5s 5s +1s (+25%) ⚪ within noise
typecheck 4s 3s–5s 4s ±0s (±0%) ⚪ within noise
CI provenance 4s 3s–4s 4s ±0s (±0%) ⚪ within noise
classify changeset release 16s 15s–17s 15s −1s (−6%) ⚪ within noise
lint 4s 4s–5s 3s −1s (−25%) ⚪ within noise
React parity checks 16s 15s–18s 13s −3s (−19%) ⚪ within noise
lint checks 9m 40s 8m 35s–11m 33s 9m 21s −19s (−3%) ⚪ within noise
Lynx compatibility 2m 10s 1m 35s–2m 55s 1m 49s −21s (−16%) ⚪ within noise
website integration suite 6m 30s 5m 59s–11m 41s 5m 58s −32s (−8%) ⚪ within noise
React parity shard (1/4) 12m 33s 10m 54s–18m 11s 12m 01s −32s (−4%) ⚪ within noise
example apps (1/3) 4m 03s 3m 12s–9m 27s 3m 30s −33s (−14%) ⚪ within noise
example apps (2/3) 4m 44s 3m 44s–9m 58s 4m 09s −35s (−12%) ⚪ within noise
Three compatibility 3m 42s 2m 41s–3m 51s 3m 03s −39s (−18%) ⚪ within noise
example apps (3/3) 4m 19s 3m 41s–6m 06s 3m 34s −45s (−17%) 🟢 faster
validate publishable packages 5m 03s 4m 32s–5m 22s 4m 13s −50s (−17%) 🟢 faster
test shard (Node 24, 4/4) 12m 54s 11m 03s–14m 15s 11m 53s −1m 01s (−8%) ⚪ within noise
test shard (Node 24, 3/4) 11m 39s 10m 05s–13m 34s 10m 32s −1m 07s (−10%) ⚪ within noise
React parity shard (4/4) 13m 19s 11m 22s–22m 17s 11m 54s −1m 25s (−11%) ⚪ within noise
typecheck checks 10m 02s 8m 33s–11m 07s 8m 25s −1m 37s (−16%) 🟢 faster
test shard (Node 24, 2/4) 14m 32s 12m 25s–15m 53s 12m 30s −2m 02s (−14%) ⚪ within noise
React parity shard (2/4) 11m 47s 10m 32s–19m 40s 9m 43s −2m 04s (−18%) 🟢 faster
React parity shard (3/4) 12m 46s 10m 11s–18m 01s 10m 17s −2m 29s (−19%) ⚪ within noise
heavy integration (browser - chromium) 16m 56s 12m 15s–19m 08s 12m 12s −4m 44s (−28%) 🟢 faster

@trueadm
trueadm marked this pull request as ready for review October 1, 2026 23:34
@trueadm
trueadm merged commit 3baa492 into main Oct 2, 2026
30 checks passed
@trueadm
trueadm deleted the claude/exciting-dhawan-f00dc7 branch October 2, 2026 00:12
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