Skip to content

fix(hydration): show suppressed text inside a rebuilt clone - #1538

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

trueadm merged 1 commit into
mainfrom
fix/rebuilt-clone-suppressed-text

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When hydration rebuilds a template whose root does not match the server node, HydrationCapability.adopt reports the structural mismatch and returns a fresh clone of the client template. If that clone's host carries suppressHydrationWarning and holds a dynamic text hole, the client text was dropped in both development and production builds:

  • Only-child hole (htext): the hole compared the template's own placeholder (" ") with the client text. Because suppression keeps the server value, it kept the placeholder, so <i suppressHydrationWarning>{x as string}</i> rendered <i> </i>.
  • Sibling hole (htextSwap): the template's <!> placeholder reads as the server's empty-text-slot stand-in. It was swapped for '', and suppression then kept that, so the text vanished: <i><u>x</u></i> instead of <i><u>x</u>ok</i>.

Only the one correct structural diagnostic was logged, so nothing pointed at the blank text.

A fresh clone holds client template DOM, not server output, so suppression has no server text to keep there. htext and htextSwap now write the client text when the suppressed host is a fresh clone (freshNodes), without recording a text mismatch. This matches how fresh clones already skip the server-value comparison in setHTML, and composes with #1533, which stops recordTextMismatch from reporting a fresh clone's placeholder on the unsuppressed path.

The new check sits on the cold branch only: it runs after the server and client text already differ, and the WeakSet lookup runs only on a suppressed host. The matching-text adoption path is unchanged. Suppression still keeps a differing server text on an element that hydration adopts from the server.

htextSwap's other branch, which installs an empty tracking node for a suppressed host with no server text node, is left unchanged: a fresh clone always carries its <!> at the hole, so it never reaches that branch. An instrumented run of the full octane project (19,601 tests) recorded zero fresh hosts there, while a positive control on adopted hosts did record hits.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test: the full local run did not complete. The Vitest main process ran out of heap after about 25 minutes on a heavily loaded machine. Before that, every failure was a timeout. The failing files (behavior-root.test.ts and five octane-events-browser files) all pass when re-run on their own; one browser failure was a Vite 504 (Outdated Optimize Dep) from a stale dependency pre-bundle. Separately, the octane and octane-prod projects passed in full on the pre-rebase head, apart from two timeout-only files that pass in isolation. CI is the full-suite evidence.
  • targeted tests: packages/octane/tests/hydration/rebuilt-clone-suppressed-text.test.ts under the octane and octane-prod projects, covering dev and prod compiles. The cases are only-child, sibling, nested-element and renderable holes in a rebuilt clone, each asserting the final DOM and exactly one structural diagnostic. Two controls check that an adopted same-tag element keeps the server text, the same node and no diagnostics. Before the fix, 6 of 12 failed (only-child, sibling and nested, in both compile modes); the renderable-hole case already passed and pins the neighbouring path.
  • pnpm typecheck:files on the changed runtime, test and .tsrx fixture.
  • Probed outside the suite: adjacent holes, a hole after a component, a hole after an @if, an empty value and mixed static text in a suppressed rebuilt clone. Each dropped its text before the fix and lands after it.

There is no benchmark for the mismatch-recovery path, so this PR makes no performance claim. The added work is one WeakSet lookup on a branch that only runs after a text mismatch on a suppressed host.

Risk / follow-ups

  • Separate, pre-existing defect: an @if inside a rebuilt clone logs a false second structural diagnostic in development ("expected <s> … end of the parent block"). It fires with or without suppression and is unchanged here; it is being handled separately.

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 hydration mismatch recovery and suppressHydrationWarning text binding in runtime.ts; behavior change is narrow (suppressed hosts on fresh clones only) but hydration paths are easy to regress.

Overview
Fixes blank text when hydration rebuilds a mismatched subtree and the rebuilt element uses suppressHydrationWarning on a dynamic text hole.

Previously, suppression always preferred “server” text, but a fresh client clone only has template placeholders—not real server output—so client text was never applied and holes rendered empty (dev and prod). htext and htextSwap now apply client text when the suppressed host is in freshNodes, and skip recordTextMismatch for suppressed hosts so recovery does not add a second text diagnostic. Adopted server elements with the same tag still keep differing server text under suppression.

Adds a changeset, a .tsrx fixture (branch mismatch → rebuilt <i>), and hydration tests for only-child, sibling, nested, and renderable holes plus controls for adopted elements.

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

When hydration rebuilds a template whose root does not match the server
node, the fresh clone holds the client template's placeholder text, not
server output. A text hole on a suppressHydrationWarning host compared
that placeholder against the client text and, honoring suppression, kept
it: `<i suppressHydrationWarning>{x as string}</i>` rendered `<i> </i>`,
and a sibling hole whose `<!>` reads as the server's empty slot dropped
its text entirely, in development and production builds.

htext and htextSwap now write the client text when the suppressed host
is a fresh clone, without recording a text mismatch. The freshness check
runs only after the server and client text already differ on a
suppressed host. Suppression still keeps a differing server text on an
adopted element.

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 01:13
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

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

Compares 3ffd8cc3c with 9d6674ca0 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)

target operation base head Δ noise
octane-tsrx replace 7.93 6.40 −19.3% ±13% 🟢 faster
octane-tsrx runlots 31.41 28.16 −10.3% ±10% 🟢 faster
All 20 timed operations (18 within noise)
target operation base head Δ noise
octane-tsrx run 3.91 3.33 −14.8% ±39% ⚪ within noise
octane-tsrx replace 7.93 6.40 −19.3% ±13% 🟢 faster
octane-tsrx add 3.78 3.40 −10.1% ±14% ⚪ within noise
octane-tsrx update 0.49 0.33 −32.7% ±38% ⚪ within noise
octane-tsrx select 0.17 0.16 −5.9% ±69% ⚪ within noise
octane-tsrx swap 0.42 0.37 −11.9% ±44% ⚪ within noise
octane-tsrx remove 0.37 0.32 −13.5% ±75% ⚪ within noise
octane-tsrx runlots 31.41 28.16 −10.3% ±10% 🟢 faster
octane-tsrx select_lots 0.24 0.23 −4.2% ±40% ⚪ within noise
octane-tsrx clear 43.79 39.47 −9.9% ±11% ⚪ within noise
octane-jsx run 4.07 3.36 −17.4% ±21% ⚪ within noise
octane-jsx replace 8.16 6.41 −21.4% ±22% ⚪ within noise
octane-jsx add 3.39 3.19 −5.9% ±28% ⚪ within noise
octane-jsx update 0.82 0.57 −30.5% ±78% ⚪ within noise
octane-jsx select 0.62 0.43 −30.6% ±81% ⚪ within noise
octane-jsx swap 0.74 0.65 −12.2% ±27% ⚪ within noise
octane-jsx remove 0.66 0.75 +13.6% ±33% ⚪ within noise
octane-jsx runlots 31.15 31.98 +2.7% ±30% ⚪ within noise
octane-jsx select_lots 2.58 2.72 +5.4% ±26% ⚪ within noise
octane-jsx clear 45.27 40.41 −10.7% ±25% ⚪ 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,087 +76 (+0.0%) 🔴
hydrate-root gzip 49,972 49,989 +17 (+0.0%) 🔴
hydrate-root brotli 43,581 43,663 +82 (+0.2%) 🔴
deferred-hydration raw 218,124 218,200 +76 (+0.0%) 🔴
deferred-hydration gzip 69,372 69,391 +19 (+0.0%) 🔴
deferred-hydration brotli 59,951 59,926 −25 (−0.0%) 🟢

99 other measured values are unchanged.

CI job durations

  • 🟢 1 job(s) faster than every recent main run: website integration suite

Compares the CI run for 0a6f73bff (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) 15m 07s 13m 32s–18m 13s 13m 32s −1m 35s (−10%) ⚪ within noise
total job time 157m 32s 150m 35s–201m 42s 154m 37s −2m 55s (−2%) ⚪ within noise
website integration suite 6m 24s 5m 49s–6m 31s 5m 45s −39s (−10%) 🟢 faster
All 26 timed jobs
job main median main range this PR Δ
React parity shard (2/4) 11m 21s 10m 32s–16m 59s 11m 55s +34s (+5%) ⚪ within noise
example apps (1/3) 3m 22s 3m 12s–6m 30s 3m 54s +32s (+16%) ⚪ within noise
example apps (3/3) 3m 44s 3m 22s–6m 06s 4m 11s +27s (+12%) ⚪ within noise
test (24) 4s 4s–5s 5s +1s (+25%) ⚪ within noise
examples 4s 4s–4s 4s ±0s (±0%) ⚪ within noise
lint 4s 4s–4s 4s ±0s (±0%) ⚪ within noise
typecheck 4s 3s–5s 4s ±0s (±0%) ⚪ within noise
CI provenance 4s 3s–5s 4s ±0s (±0%) ⚪ within noise
classify changeset release 16s 15s–17s 15s −1s (−6%) ⚪ within noise
validate publishable packages 4m 47s 3m 58s–5m 22s 4m 45s −2s (−1%) ⚪ within noise
React parity checks 16s 14s–18s 14s −2s (−13%) ⚪ within noise
example apps (2/3) 3m 52s 3m 41s–6m 33s 3m 43s −9s (−4%) ⚪ within noise
heavy integration (browser - chromium) 12m 57s 12m 15s–17m 24s 12m 46s −11s (−1%) ⚪ within noise
test shard (Node 24, 1/4) 12m 57s 10m 39s–16m 33s 12m 46s −11s (−1%) ⚪ within noise
test shard (Node 24, 4/4) 11m 22s 11m 03s–14m 15s 10m 57s −25s (−4%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 5m 47s 5m 30s–9m 13s 5m 21s −26s (−7%) ⚪ within noise
Lynx compatibility 2m 07s 1m 35s–2m 19s 1m 39s −28s (−22%) ⚪ within noise
typecheck checks 9m 14s 8m 23s–11m 07s 8m 37s −37s (−7%) ⚪ within noise
website integration suite 6m 24s 5m 49s–6m 31s 5m 45s −39s (−10%) 🟢 faster
test shard (Node 24, 3/4) 10m 54s 10m 05s–13m 34s 10m 15s −39s (−6%) ⚪ within noise
test shard (Node 24, 2/4) 13m 18s 10m 41s–15m 15s 12m 34s −44s (−6%) ⚪ within noise
React parity shard (1/4) 12m 04s 10m 54s–13m 55s 11m 17s −47s (−6%) ⚪ within noise
Three compatibility 3m 42s 2m 41s–3m 51s 2m 45s −57s (−26%) ⚪ within noise
React parity shard (4/4) 12m 09s 10m 46s–15m 11s 11m 09s −1m 00s (−8%) ⚪ within noise
lint checks 9m 40s 7m 55s–11m 33s 8m 33s −1m 07s (−12%) ⚪ within noise
React parity shard (3/4) 12m 05s 10m 11s–13m 05s 10m 55s −1m 10s (−10%) ⚪ within noise

@trueadm
trueadm merged commit 5f354d2 into main Oct 2, 2026
52 checks passed
@trueadm
trueadm deleted the fix/rebuilt-clone-suppressed-text branch October 2, 2026 07:28
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