Skip to content

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

Merged
trueadm merged 4 commits into
mainfrom
claude/sharp-williams-218b64
Oct 2, 2026
Merged

trueadm merged 4 commits into
mainfrom
claude/sharp-williams-218b64

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds hydration regression tests for a single-root component call that renders through the full component slot and is rebuilt over a mismatched server element in place. This is test-only, with no runtime change and no changeset.

The defect was reported against a base without #1561. Hydrating a hooked single-root call where the server had rendered a different element threw NotFoundError: The child can not be found in the parent. from commitBag, and hydrateRoot left the container blank. adopt() discarded the server node at the cursor while it was still the new block's insert anchor (state.anchor / endMarker). A production compile turns a call whose output reads only constants into componentSlotVoid, so that call took the same path and crashed too.

#1561 already fixes this on main. adopt() now keeps the mismatched node until the rebuilt root commits, and rebuiltAt removes it at that point. The single-root finally stamps the block on the rebuilt root. These tests pin that behavior for the reported shape: the call sits in a host element (<section>) inside an @if arm, with adopted server siblings on both sides.

Validation

  • pnpm format:check, not run repo-wide. pnpm format:files:check passes on the two new files.
  • pnpm typecheck, not run repo-wide. pnpm typecheck:files passes on the two new files.
  • pnpm test, not run locally. CI covers it.
  • targeted tests: vitest run --project octane packages/octane/tests/hydration/in-place-mismatch-full.test.ts
  • pnpm sync (no generated changes) and node scripts/check-test-markers.mjs

Each case checks:

  • the rebuilt markup, <em>e</em><p>…</p><b>p</b><hr>;
  • that the server <section>, <em>, <b> and <hr> keep their identity and the <u> is gone;
  • exactly one recoverable code-51 report, and one structural warning only in a development compile;
  • that toggling the arm off and on renders correctly;
  • that unmount leaves the container empty.

Risk / follow-ups

  • Lite slot, development compile. A development compile renders the hookless constant-output call through the lite slot (componentSlotLite). Before Fix hydration mismatch in lite component hosts #1593 that path kept the server <u> and put the rebuilt <p> in front of it. Fix hydration mismatch in lite component hosts #1593 merged while this PR was open, so the case now runs in all three modes.
  • Dynamic identity swap. After an in-place rebuild, state.anchor still points at the removed server node, but it is only read when the slot swaps component identity. A compiled call hydrated in place always calls the same component and has no key. The reachable dynamic swap, a component that returns <C /> with C chosen per render, anchors on its range marker. I checked it after a mismatched hydration and it works, so no test was added for it.

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

Low Risk
Test-only additions under packages/octane/tests/hydration with no production code changes.

Overview
Adds regression coverage for hydrating a single-root full component slot when the server left a different element at the cursor (e.g. <u> vs client <p>), so the client rebuilds the component root in place instead of crashing.

Introduces fixture in-place-mismatch-full.tsrx with an @if arm that swaps a placeholder <u> for either a hooked component (Para) or a constant-output component (Constant), plus shared siblings (Em, Leaf, <hr>). New in-place-mismatch-full.test.ts runs six cases (both call shapes × development compile, production compile, and production runtime) and asserts DOM identity, one recoverable mismatch (#51), optional dev-only structural warnings, arm toggle remount behavior, and clean unmount.

No runtime or compiler changes—this pins behavior already fixed on main (#1561 / related slot work).

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

…ement 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]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent test PR: tests only labels Oct 2, 2026
@github-actions
github-actions Bot marked this pull request as draft October 2, 2026 18:58
@trueadm
trueadm marked this pull request as ready for review October 2, 2026 18:58
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 29 value(s) increased
  • 🔴 bundle-reachability: 34 value(s) increased

Compares 5ef4f9a49 with 0aa932454 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.52 3.57 +1.4% ±7% ⚪ within noise
octane-tsrx replace 7.39 8.26 +11.8% ±57% ⚪ within noise
octane-tsrx add 3.67 3.69 +0.5% ±27% ⚪ within noise
octane-tsrx update 0.31 0.37 +19.4% ±88% ⚪ within noise
octane-tsrx select 0.14 0.17 +21.4% ±67% ⚪ within noise
octane-tsrx swap 0.32 0.41 +28.1% ±57% ⚪ within noise
octane-tsrx remove 0.25 0.30 +20.0% ±52% ⚪ within noise
octane-tsrx runlots 32.93 36.10 +9.6% ±15% ⚪ within noise
octane-tsrx select_lots 0.18 0.17 −5.6% ±75% ⚪ within noise
octane-tsrx clear 31.11 34.68 +11.5% ±28% ⚪ within noise
octane-jsx run 4.23 4.54 +7.3% ±30% ⚪ within noise
octane-jsx replace 7.35 9.17 +24.8% ±31% ⚪ within noise
octane-jsx add 3.38 3.57 +5.6% ±9% ⚪ within noise
octane-jsx update 0.48 0.55 +14.6% ±17% ⚪ within noise
octane-jsx select 0.37 0.35 −5.4% ±37% ⚪ within noise
octane-jsx swap 0.64 0.67 +4.7% ±42% ⚪ within noise
octane-jsx remove 0.51 0.49 −3.9% ±43% ⚪ within noise
octane-jsx runlots 31.83 33.44 +5.1% ±17% ⚪ within noise
octane-jsx select_lots 2.64 3.03 +14.8% ±37% ⚪ within noise
octane-jsx clear 35.05 35.27 +0.6% ±22% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 126,796 126,863 +67 (+0.1%) 🔴
octane-tsrx js_gzip 41,944 41,967 +23 (+0.1%) 🔴
octane-tsrx js_brotli 36,928 36,957 +29 (+0.1%) 🔴
octane-tsrx app_gzip 2,564 2,563 −1 (−0.0%) 🟢
octane-tsrx app_brotli 2,225 2,226 +1 (+0.0%) 🔴
octane-tsrx fw_raw 119,284 119,351 +67 (+0.1%) 🔴
octane-tsrx fw_gzip 39,380 39,404 +24 (+0.1%) 🔴
octane-tsrx fw_brotli 34,703 34,731 +28 (+0.1%) 🔴
octane-tsrx todo_js_raw 141,739 141,806 +67 (+0.0%) 🔴
octane-tsrx todo_js_gzip 46,792 46,812 +20 (+0.0%) 🔴
octane-tsrx todo_js_brotli 40,969 40,963 −6 (−0.0%) 🟢
octane-tsrx todo_fw_raw 136,629 136,696 +67 (+0.0%) 🔴
octane-tsrx todo_fw_gzip 44,315 44,335 +20 (+0.0%) 🔴
octane-tsrx todo_fw_brotli 38,852 38,846 −6 (−0.0%) 🟢
octane-tsrx chat_js_raw 140,984 141,051 +67 (+0.0%) 🔴
octane-tsrx chat_js_gzip 46,766 46,781 +15 (+0.0%) 🔴
octane-tsrx chat_js_brotli 41,046 41,136 +90 (+0.2%) 🔴
octane-tsrx chat_app_gzip 2,978 2,979 +1 (+0.0%) 🔴
octane-tsrx chat_app_brotli 2,632 2,627 −5 (−0.2%) 🟢
octane-tsrx chat_fw_raw 134,331 134,398 +67 (+0.0%) 🔴
octane-tsrx chat_fw_gzip 43,788 43,802 +14 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 38,414 38,509 +95 (+0.2%) 🔴
octane-tsrx weather_js_raw 177,593 177,747 +154 (+0.1%) 🔴
octane-tsrx weather_js_gzip 58,066 58,105 +39 (+0.1%) 🔴
octane-tsrx weather_js_brotli 50,546 50,495 −51 (−0.1%) 🟢
octane-tsrx weather_app_gzip 9,044 9,045 +1 (+0.0%) 🔴
octane-tsrx weather_app_brotli 7,590 7,559 −31 (−0.4%) 🟢
octane-tsrx weather_fw_raw 150,858 151,012 +154 (+0.1%) 🔴
octane-tsrx weather_fw_gzip 49,022 49,060 +38 (+0.1%) 🔴
octane-tsrx weather_fw_brotli 42,956 42,936 −20 (−0.0%) 🟢
octane-jsx js_raw 226,031 226,315 +284 (+0.1%) 🔴
octane-jsx js_gzip 72,141 72,213 +72 (+0.1%) 🔴
octane-jsx js_brotli 62,398 62,452 +54 (+0.1%) 🔴
octane-jsx app_gzip 2,944 2,941 −3 (−0.1%) 🟢
octane-jsx app_brotli 2,502 2,498 −4 (−0.2%) 🟢
octane-jsx fw_raw 217,564 217,848 +284 (+0.1%) 🔴
octane-jsx fw_gzip 69,197 69,272 +75 (+0.1%) 🔴
octane-jsx fw_brotli 59,896 59,954 +58 (+0.1%) 🔴

7 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 116,488 116,555 +67 (+0.1%) 🔴
cli-spa-starter gzip 39,324 39,345 +21 (+0.1%) 🔴
cli-spa-starter brotli 34,355 34,351 −4 (−0.0%) 🟢
root-static raw 202,351 202,635 +284 (+0.1%) 🔴
root-static gzip 64,323 64,419 +96 (+0.1%) 🔴
root-static brotli 55,751 55,828 +77 (+0.1%) 🔴
context raw 110,385 110,469 +84 (+0.1%) 🔴
context gzip 36,548 36,585 +37 (+0.1%) 🔴
context brotli 32,347 32,359 +12 (+0.0%) 🔴
hydrate-root raw 165,971 166,199 +228 (+0.1%) 🔴
hydrate-root gzip 52,973 53,027 +54 (+0.1%) 🔴
hydrate-root brotli 46,086 46,168 +82 (+0.2%) 🔴
deferred-hydration raw 228,777 229,105 +328 (+0.1%) 🔴
deferred-hydration gzip 72,592 72,692 +100 (+0.1%) 🔴
deferred-hydration brotli 62,644 62,705 +61 (+0.1%) 🔴
suspense-transition raw 166,916 167,001 +85 (+0.1%) 🔴
suspense-transition gzip 53,658 53,678 +20 (+0.0%) 🔴
suspense-transition brotli 46,871 46,886 +15 (+0.0%) 🔴
binding-base-ui-vite raw 212,541 212,826 +285 (+0.1%) 🔴
binding-base-ui-vite gzip 67,904 67,997 +93 (+0.1%) 🔴
binding-base-ui-vite brotli 58,859 58,985 +126 (+0.2%) 🔴
binding-base-ui-esbuild raw 210,506 210,787 +281 (+0.1%) 🔴
binding-base-ui-esbuild gzip 67,896 67,965 +69 (+0.1%) 🔴
binding-base-ui-esbuild brotli 58,891 58,943 +52 (+0.1%) 🔴
binding-radix-vite raw 214,470 214,756 +286 (+0.1%) 🔴
binding-radix-vite gzip 68,444 68,558 +114 (+0.2%) 🔴
binding-radix-vite brotli 59,365 59,397 +32 (+0.1%) 🔴
binding-radix-esbuild raw 212,394 212,677 +283 (+0.1%) 🔴
binding-radix-esbuild gzip 68,496 68,546 +50 (+0.1%) 🔴
binding-radix-esbuild brotli 59,446 59,445 −1 (−0.0%) 🟢
binding-apollo-client-vite raw 357,594 357,881 +287 (+0.1%) 🔴
binding-apollo-client-vite gzip 112,014 112,125 +111 (+0.1%) 🔴
binding-apollo-client-vite brotli 97,791 97,861 +70 (+0.1%) 🔴
binding-apollo-client-esbuild raw 360,546 360,834 +288 (+0.1%) 🔴
binding-apollo-client-esbuild gzip 114,237 114,337 +100 (+0.1%) 🔴
binding-apollo-client-esbuild brotli 99,510 99,545 +35 (+0.0%) 🔴

69 other measured values are unchanged.

trueadm and others added 2 commits October 2, 2026 20:33
…pment 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]>

@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 is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit 8fe37ca. Configure here.

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]>
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 test PR: tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant