Repository navigation
fix(hydration): report a rebuilt clone's mismatch once - #1533
Merged
Merged
Conversation
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 text holes still bound through the hydrating text path and compared the template's own placeholder as server text, so development builds logged a second, false text mismatch for the same recovery. recordTextMismatch now skips text whose host was built fresh by mismatch recovery. The check runs only on the cold mismatch path. A genuine text mismatch inside an adopted server element still reports. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 1, 2026 23:51
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 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
recordTextMismatchskips text whose host was built fresh by mismatch recovery. The fresh clone holds the client template's own placeholder (" "for an only-child hole,<!---->swapped to""for a sibling hole), not server text.Repro (pre-existing on main):
The server renders
{ server: true }and the client hydrates{}. Before this fix, dev logged:…the client expected <i> but the server rendered <b>. The mismatched subtree was rebuilt on the client.(correct)…server rendered text " " but the client rendered "ok"…(false)The same duplicate appeared for sibling text holes, inside
@trybodies, against a server@pendingarm, and after a render-phase update during hydration.onRecoverableErroralready fired once because reports coalesce, and the final DOM was already correct.Changes
packages/octane/src/runtime.ts: a guard inHydrationCapability.recordTextMismatchchecksfreshNodes.has(parentNode). It checks the parent rather than the node because the sibling-hole path replaces the clone's<!---->with a new, unmarked Text node.packages/octane/tests/hydration/rebuilt-clone-text.test.tsplus its fixture: dev and prod compile regressions. Each case asserts exactly one structural diagnostic, no text diagnostic, one structuralonRecoverableError, and the correct final DOM. A same-tag control asserts a genuine server text mismatch still reports.octane.Performance
node benchmarks/bundle-size/run-minimal.mjs hydrate-root deferred-hydration suspense-transition, baseline =HEADruntime, same machine):hydrate-root: 155342 → 155380 raw (+38), 49745 → 49758 gzip (+13), 43374 → 43429 brotli (+55)deferred-hydration: +38 raw / +12 gzip / +36 brotlisuspense-transition(no hydration): unchangedValidation
pnpm format:check(not run repo-wide;pnpm format:files:checkon every changed file passes)pnpm typecheck(not run repo-wide;pnpm typecheck:fileson the changed runtime, test, and.tsrxfixture passes)pnpm test(not run in full; see the targeted Vitest runs below)recordTextMismatchalways skip fails the genuine-text control in dev and prod, in both projects.vitest run --project octane --project octane-prod(all files) on the pre-rebase head: 1291 files / 35729 tests passed.--project octane --project octane-prod packages/octane/tests/hydration/ packages/octane/tests/map-destructured-param-write.test.ts: 210 files / 11158 tests passed.pnpm syncleft no generated changes.Risk / follow-ups
markFreshtarget is a client-created element or comment, and client-built hosts render their children with hydration suspended. A fresh parent therefore never holds server text, so the guard cannot hide a real mismatch.title/class/styleon the same rebuilt clone log false value diagnostics throughallowAttribute/allowClass/the style check.suppressHydrationWarningthere may also keep the template's missing attribute instead of the client value.@trybody that suspends after its clone was rebuilt reports the structural mismatch twice and firesonRecoverableErrortwice. The server content is also removed while the body is pending.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Narrow change to dev/prod hydration mismatch reporting on an already-mismatched path; genuine adopted-server text mismatches remain reported.
Overview
Fixes duplicate hydration diagnostics when mismatch recovery rebuilds a template clone whose root does not match server markup. Development builds previously logged the correct structural rebuild warning and a second, false server-rendered text warning because text holes in the fresh clone were compared against the client template’s placeholder, not real server text.
HydrationCapability.recordTextMismatchnow returns early when the text node’s parent is infreshNodes(client-built during recovery), including sibling-hole cases where the text node itself is replaced. Genuine text mismatches inside adopted server elements are unchanged.Adds a hydration fixture and Vitest coverage (dev and prod compile) for
@if,@try,@pending, render-phase updates, sibling text holes, plus a control that still expects a real text mismatch. Includes anoctanepatch changeset.Reviewed by Cursor Bugbot for commit 6ccbcff. Bugbot is set up for automated code reviews on this repo. Configure here.