Repository navigation
fix(hydration): apply a rebuilt clone's attributes without a value report - #1536
Merged
Merged
Conversation
…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]>
trueadm
marked this pull request as ready for review
October 2, 2026 00:46
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 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
2 of 5 tasks
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 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, andstylestill went through the hydrating value comparison, against the client template's own empty values. This caused two defects:<i>but the server rendered<b>… rebuilt on the client"), development builds logged a false value mismatch for each binding, such asattribute `title` null but the client rendered "ok".suppressHydrationWarningon the rebuilt element, the "keep the server value" rule kept the template's empty placeholder. Dynamic attributes,class, andstylewere silently dropped (<i>t</i>instead of<i title="ok" class="ok" style="color: red;">t</i>).allowAttribute,allowClass, andapplyStyleinHydrationCapabilitynow 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
isFreshlookup 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):Validation
pnpm format:checkpnpm typecheck: not run repo-wide;pnpm typecheck:fileson the changed runtime, test, and.tsrxfixture is cleanpnpm test: not run; theoctane+octane-prodprojects were run instead (below)packages/octane/tests/hydration/rebuilt-clone-attrs.test.ts, under dev and prod compile:onRecoverableError, and only the structural warning in dev.octane+octane-prodbefore the rebase onto currentmain: 1293 files, 35,757 tests, all passed.behavior-root.test.tsandhydration-ssr-diagnostics.test.tsonly. Both files pass in isolation in both projects (430 tests), and they also pass in isolation againstmain's runtime.pnpm changeset:checkpasses.Risk / follow-ups
freshNodesnow 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.<i> </i>) instead of the client text, becausehtextapplies the same "keep the server value" rule.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 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>).HydrationCapabilitynow treats fresh mismatch clones (isFresh) like ordinary client DOM:allowAttribute,allowClass, andapplyStyleapply client values without extra dev value-mismatch noise, andsuppressHydrationWarningno 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-attrsfixture/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.