Repository navigation
fix(hydration): show suppressed text inside a rebuilt clone - #1538
Merged
Merged
Conversation
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]>
trueadm
marked this pull request as ready for review
October 2, 2026 01:13
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (18 within noise)
Application bundle size (bytes)No changes across 45 measured values. Public-import reachability bundles (bytes)
99 other measured values are unchanged. CI job durations
Compares the CI run for
All 26 timed jobs
|
This was referenced Oct 2, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When hydration rebuilds a template whose root does not match the server node,
HydrationCapability.adoptreports the structural mismatch and returns a fresh clone of the client template. If that clone's host carriessuppressHydrationWarningand holds a dynamic text hole, the client text was dropped in both development and production builds: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>.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.
htextandhtextSwapnow 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 insetHTML, and composes with #1533, which stopsrecordTextMismatchfrom 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 fulloctaneproject (19,601 tests) recorded zero fresh hosts there, while a positive control on adopted hosts did record hits.Validation
pnpm format:checkpnpm typecheckpnpm 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.tsand fiveoctane-events-browserfiles) all pass when re-run on their own; one browser failure was a Vite504 (Outdated Optimize Dep)from a stale dependency pre-bundle. Separately, theoctaneandoctane-prodprojects passed in full on the pre-rebase head, apart from two timeout-only files that pass in isolation. CI is the full-suite evidence.packages/octane/tests/hydration/rebuilt-clone-suppressed-text.test.tsunder theoctaneandoctane-prodprojects, 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:fileson the changed runtime, test and.tsrxfixture.@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
@ifinside 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
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches hydration mismatch recovery and
suppressHydrationWarningtext binding inruntime.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
suppressHydrationWarningon 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).
htextandhtextSwapnow apply client text when the suppressed host is infreshNodes, and skiprecordTextMismatchfor 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
.tsrxfixture (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.