Skip to content

fix(hydration): apply a rebuilt clone's attributes without a value report - #1536

Merged
trueadm merged 1 commit into
mainfrom
fix/rebuilt-clone-attrs
Oct 2, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/rebuilt-clone-attrs

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When a template's root does not match the server node, hydration reports the structural mismatch and clones the template fresh on the client. That clone's dynamic attributes, class, and style still went through the hydrating value comparison, against the client template's own empty values. This caused two defects:

  • False diagnostics (dev). After the one correct structural warning ("the client expected <i> but the server rendered <b>… rebuilt on the client"), development builds logged a false value mismatch for each binding, such as attribute `title` null but the client rendered "ok".
  • Dropped client values (dev and prod). With suppressHydrationWarning on the rebuilt element, the "keep the server value" rule kept the template's empty placeholder. Dynamic attributes, class, and style were silently dropped (<i>t</i> instead of <i title="ok" class="ok" style="color: red;">t</i>).

allowAttribute, allowClass, and applyStyle in HydrationCapability now apply the client value silently on a fresh clone, even when it is suppressed. There is no server value there to compare or keep. This follows the text-hole fix in #1533.

Performance

Every new isFresh lookup runs only after the server and client values already differ, or for a suppressed element. With a production compile and no suppression (mode === 0), the check short-circuits first, so the production happy path is unchanged. Size of a minified production hydrate + attribute/class/style setter bundle (esbuild):

raw gzip brotli
baseline 270,629 85,636 73,601
candidate 270,681 85,646 73,578
delta +52 +10 −23 (noise)

Validation

  • pnpm format:check
  • pnpm typecheck: not run repo-wide; pnpm typecheck:files on the changed runtime, test, and .tsrx fixture is clean
  • pnpm test: not run; the octane + octane-prod projects were run instead (below)
  • targeted tests:
    • New packages/octane/tests/hydration/rebuilt-clone-attrs.test.ts, under dev and prod compile:
      • Rebuilt clones with direct bindings, suppressed bindings, a nested element, spread props, and suppressed spread props. Each asserts the final DOM, exactly one structural onRecoverableError, and only the structural warning in dev.
      • Controls: a genuine same-tag mismatch still patches, keeps the adopted node, and reports all three value warnings in dev. A suppressed adopted element still keeps the server values.
    • The new test failed before the fix: 7 of 14 tests, for exactly the reported reasons. Reverting each of the four guards one at a time also turns it red.
    • octane + octane-prod before the rebase onto current main: 1293 files, 35,757 tests, all passed.
    • On the rebased head, under a machine load average of about 40 from other concurrent Vitest runs, the full run hit timeouts and worker-process crashes in behavior-root.test.ts and hydration-ssr-diagnostics.test.ts only. Both files pass in isolation in both projects (430 tests), and they also pass in isolation against main's runtime.
    • pnpm changeset:check passes.

Risk / follow-ups

  • Any element in freshNodes now always takes client attribute, class, and style values during hydration, including elements other client-build paths mark fresh. All of those are client-created DOM, so there is no server value to keep there either.
  • A follow-up is being worked separately: a suppressed text hole on a rebuilt clone renders the template placeholder (<i> </i>) instead of the client text, because htext applies the same "keep the server value" rule.

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 write paths for attributes, class, and style on all nodes marked fresh during recovery; behavior on adopted server nodes is explicitly preserved by tests but any other fresh-node paths now always take client values.

Overview
Fixes hydration attribute/class/style handling on client-rebuilt subtrees after a structural mismatch (e.g. expected <i>, server had <b>).

HydrationCapability now treats fresh mismatch clones (isFresh) like ordinary client DOM: allowAttribute, allowClass, and applyStyle apply client values without extra dev value-mismatch noise, and suppressHydrationWarning no longer blocks those writes on the clone (there is no real server value—only template placeholders). Adopted server elements are unchanged: real value mismatches still warn in dev, and suppression still keeps server attrs/style.

Adds rebuilt-clone-attrs fixture/tests (direct, nested, spread, suppressed bindings; dev + prod compile) and an octane patch changeset.

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

…port

When a template's root does not match the server node, hydration reports
the structural mismatch and clones the template fresh on the client. That
clone's dynamic attributes, class, and style still went through the
hydrating comparison against the client template, so development builds
logged false value mismatches after the structural one. With
suppressHydrationWarning on the rebuilt element, the "keep the server
value" rule kept the template's empty placeholder and dropped the client
values in development and production.

allowAttribute, allowClass, and applyStyle now apply the client value
silently on a fresh clone. The checks run only after a mismatch or for a
suppressed element, so the production happy path is unchanged. A genuine
mismatch on an adopted element still reports, and suppression still keeps
the server value there.

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 00:46
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-reachability: 4 value(s) increased

Compares 3ffd8cc3c with 0d0736bf9 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 3.50 3.48 −0.6% ±27% ⚪ within noise
octane-tsrx replace 7.19 7.64 +6.3% ±33% ⚪ within noise
octane-tsrx add 3.26 3.50 +7.4% ±12% ⚪ within noise
octane-tsrx update 0.40 0.32 −20.0% ±43% ⚪ within noise
octane-tsrx select 0.19 0.19 −0.0% ±90% ⚪ within noise
octane-tsrx swap 0.38 0.38 ±0.0% ±30% ⚪ within noise
octane-tsrx remove 0.34 0.39 +14.7% ±56% ⚪ within noise
octane-tsrx runlots 29.06 29.53 +1.6% ±13% ⚪ within noise
octane-tsrx select_lots 0.25 0.23 −8.0% ±52% ⚪ within noise
octane-tsrx clear 39.77 41.59 +4.6% ±13% ⚪ within noise
octane-jsx run 3.40 3.62 +6.5% ±22% ⚪ within noise
octane-jsx replace 6.50 7.35 +13.1% ±13% ⚪ within noise
octane-jsx add 2.97 3.29 +10.8% ±15% ⚪ within noise
octane-jsx update 0.49 0.56 +14.3% ±41% ⚪ within noise
octane-jsx select 0.42 0.37 −11.9% ±41% ⚪ within noise
octane-jsx swap 0.63 0.62 −1.6% ±36% ⚪ within noise
octane-jsx remove 0.51 0.61 +19.6% ±28% ⚪ within noise
octane-jsx runlots 27.40 28.37 +3.5% ±8% ⚪ within noise
octane-jsx select_lots 2.09 2.46 +17.7% ±26% ⚪ within noise
octane-jsx clear 39.75 41.27 +3.8% ±10% ⚪ within noise

Application bundle size (bytes)

No changes across 45 measured values.

Public-import reachability bundles (bytes)

target metric base head Δ
hydrate-root raw 156,011 156,063 +52 (+0.0%) 🔴
hydrate-root gzip 49,972 49,979 +7 (+0.0%) 🔴
hydrate-root brotli 43,581 43,547 −34 (−0.1%) 🟢
deferred-hydration raw 218,124 218,176 +52 (+0.0%) 🔴
deferred-hydration gzip 69,372 69,378 +6 (+0.0%) 🔴
deferred-hydration brotli 59,951 59,921 −30 (−0.1%) 🟢

99 other measured values are unchanged.

CI job durations

  • 🟡 1 job(s) slower than every recent main run: heavy integration (package builds, eval corpus, runtime loaders, Astro)
  • 🟢 1 job(s) faster than every recent main run: website integration suite

Compares the CI run for ae2dd6b59 (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 time excludes runner setup.

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

@trueadm
trueadm merged commit 3041f5d into main Oct 2, 2026
74 of 78 checks passed
@trueadm
trueadm deleted the fix/rebuilt-clone-attrs branch October 2, 2026 11:02
trueadm added a commit that referenced this pull request Oct 3, 2026
…aptures (#1636)

* fix(hydration): recover silently and take client values under stale captures

When a dormant <Hydrate> boundary's captures change before it activates, the
server HTML predates the client's state, so activation is meant to repair it
without onRecoverableError or a dev warning. Each recovery site tested
staleServerValues itself, and several never did: a renderable hole whose
server text became a component (code 55), a shrinking createElement child list
(62), and a changed dynamic host tag (51) still reported in dev and prod.

Gate once instead: noteRecoverableHydrationError and logHydrationMismatch
return when the current hydration is stale, and every inline
!this.staleServerValues check is gone. reportStructural no longer returns
whether it reported, since warnings gate centrally.

Under the same stale captures, suppressHydrationWarning and
dangerouslySetInnerHTML kept the server's older value after activation, and
dangerouslySetInnerHTML also logged a false dev warning. One predicate,
HydrationCapability.keepsServerValue (suppressed, not freshly rebuilt, not
stale), now decides at every text, attribute, class, and style site, folding in
the fresh-clone checks from #1536 and #1538. setHTML writes the client's HTML
when stale. Unchanged captures still report and keep server values as before.

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

* fix(hydration): undo a stale HTML repair with its attempt, and fill a suppressed lost text node

Under stale captures setHTML wrote the client's HTML through the client write
path, whose removal of the server's children is deferred to the root's
commit. A resolved @Try arm that wrote it and then suspended therefore showed
the client's HTML beside server content while pending, unlike text, and a
naive save() would leave the article empty once the deferred removal ran.
HydrationCapability.repairHTML now replaces the server's children in place
after save(el), as text repairs do, so the discarded attempt restores them for
its retry. It is a method, so bundles that never hydrate do not retain it.

htextSwap's branch for a server that rendered no text node still decided
with isHydrationSuppressed, so a suppressed host under stale captures got an
empty node instead of the client's text. It now uses keepsServerValue, and
saves the host before inserting non-empty client text.

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