Repository navigation
fix(hydration): keep server values in a suspended @try arm and report once at commit - #1544
Merged
Merged
Conversation
… once at commit A resolved @Try arm (server emitted oct-suspense:N) hydrates speculatively: when its first attempt suspends, the attempt is discarded and a later one adopts the same server nodes. An attempt that repaired a text or attribute value before suspending wrote the client value into the server's markup while the arm was still pending, and queued the text warning on a capability that the suspension dropped. The committing attempt then found the value already matching, so the mismatch never reached onRecoverableError or the dev warning. The arm's HydrationCapability is now speculative. Before it overwrites a server text value, attribute, class or style, it records the server value, and rollback() restores them when the attempt suspends or throws. Nodes cloned fresh by structural recovery hold client template values and are skipped. Value warnings (attribute, class, style, kept dangerouslySetInnerHTML) are held until the attempt settles. A nested arm that commits inside an enclosing speculative attempt hands its records and pending warnings to that attempt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ue-repair # Conflicts: # packages/octane/src/runtime.ts
trueadm
marked this pull request as ready for review
October 2, 2026 08:55
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)
38 other measured values are unchanged. Public-import reachability bundles (bytes)
78 other measured values are unchanged. CI job durations⚪ No job outside the range of recent Compares the CI run for
All 26 timed jobs
|
… attempt Move the speculative check and the server-value read into HydrationCapability.repaired(), so each repair site is one call. A non-speculative hydration no longer reads the class or style attribute at all on the mismatch path, and hydrate-root / deferred-hydration shrink by 87 raw bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ue-repair # Conflicts: # docs/differences-from-react.md # packages/octane/src/runtime.ts
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
…ition Keep both sides in renderInitialSuspenseHydration: the attempt's capability is speculative (#1544) and shares the set of client-built nodes across attempts. Adapt the rebuilt-tail sweep to main's root hydration journal: save() the parent before removing the tail, and sweep only while the rebuilt root still stands right before it, so a rolled-back attempt's stale tail is never swept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
…ttempt rebuilt a mismatch (#1560) * fix(hydration): keep server values in a suspended @Try arm and report once at commit A resolved @Try arm (server emitted oct-suspense:N) hydrates speculatively: when its first attempt suspends, the attempt is discarded and a later one adopts the same server nodes. An attempt that repaired a text or attribute value before suspending wrote the client value into the server's markup while the arm was still pending, and queued the text warning on a capability that the suspension dropped. The committing attempt then found the value already matching, so the mismatch never reached onRecoverableError or the dev warning. The arm's HydrationCapability is now speculative. Before it overwrites a server text value, attribute, class or style, it records the server value, and rollback() restores them when the attempt suspends or throws. Nodes cloned fresh by structural recovery hold client template values and are skipped. Value warnings (attribute, class, style, kept dangerouslySetInnerHTML) are held until the attempt settles. A nested arm that commits inside an enclosing speculative attempt hands its records and pending warnings to that attempt. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(hydration): read the repaired server value only in a speculative attempt Move the speculative check and the server-value read into HydrationCapability.repaired(), so each repair site is one call. A non-speculative hydration no longer reads the class or style attribute at all on the mismatch path, and hydrate-root / deferred-hydration shrink by 87 raw bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(hydration): keep a suspended @Try arm's server content when its attempt rebuilt a mismatch A resolved @Try arm (oct-suspense:N) whose first hydrating attempt rebuilt a mismatched template clone and then suspended removed the server node while the attempt was discarded, left the arm blank while pending, and reported the structural mismatch twice (dev warning and onRecoverableError, dev and prod): the retry found only the range's close marker and reported again. A speculative attempt now keeps one undo list. save(parent) snapshots a parent's children once before structural recovery changes them (the same sites #1556 journals for roots, plus the de-opt reconcile); remember() makes HYDRATION_REBUILT marks undoable; #1544's value repairs push restore steps onto the same list. settle() hands the list to an enclosing speculative attempt and rollback() replays it newest first. Any failed attempt rolls back and drops its held diagnostics, so the attempt that commits reports each mismatch once. #1544's heldWarnings/repairs log fold into this list and #1534's hold. collectRootRange/restoreRootRange are shared with journalRootRange, and a dormant island's staleServerValues now carries to retries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(hydration): undo de-opt children a suspended @Try arm inserted or moved reconcileDeoptChildren recorded a speculative snapshot of a server host only when it removed a child. Filling an empty server host, or inserting and moving children in its ordering pass, journaled only for the root, so a resolved @Try arm that hit those paths and then suspended left client-built children in the server markup while pending. Record the host before both, through a cold helper that does nothing outside a hydrating attempt or for a fresh host. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(hydration): skip restoring a range whose bounds left their parent The speculative arm's undo called restoreRootRange without the check that journalRootRange makes first: when either bound is no longer in the parent, the snapshot owns no range there, and walking to a bound that is gone sweeps the parent's later siblings and then inserts before a detached anchor. Move the check into restoreRootRange so both callers share it. Recovery cannot detach an arm's own bounds in balanced markup; the regression simulates an outside mutation during the suspended attempt. 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
A resolved
@tryarm (server emittedoct-suspense:N, hydrated byrenderInitialSuspenseHydration) whose first hydrating attempt repairs a text or attribute value and then suspends now keeps the server's value while pending, and reports the mismatch once when an attempt commits.Why
The arm hydrates speculatively: a suspended attempt is discarded and a later one adopts the same server nodes. Before this change:
htext/htextSwapwrote the client value immediately, so the server's text showed the client value while the arm was still pending.textWarnings, which only publish on success. The suspension dropped the capability, and the retry saw matching text. As a result, neither the dev "server rendered text … but the client rendered …" warning noronRecoverableErrorfired.dangerouslySetInnerHTMLcontent warned on every attempt.Without suspension, the same arm reports one warning and one
onRecoverableError. The fix makes the suspended case match.Changes
HydrationCapability.speculativeis set only byrenderInitialSuspenseHydration.flushClassWrites) or style, a speculative attempt records the server value. Recording happens only on the mismatch path, never on the happy path.rollback()restores the recorded values newest first, on suspension or error. Nodes cloned fresh by structural recovery are skipped: they hold client template values, and restoring them made the retry report false mismatches.dangerouslySetInnerHTMLwarning. The hold goes throughwarnHeldHydrationMismatch, whose call sites are all dev-gated, so production bundles drop it.settle(outer)replacesflushTextWarnings()on success. An arm that commits inside an enclosing speculative attempt hands its records and pending warnings to that attempt. Otherwise they publish through fix(octane): drop hydration diagnostics from try bodies caught by their catch arm #1534's diagnostic hold, as before.rollback(), the capability stops being speculative. An adopted server catch arm keeps reporting immediately.octanepatch) and one sentence in the hydration section ofdocs/differences-from-react.md.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkon every changed file passes.pnpm typecheck: not run repo-wide.pnpm typecheck:filesonruntime.ts, the new test and the.tsrxfixture passes.pnpm test: not run. Theoctaneandoctane-prodvitest projects were run instead (below).packages/octane/tests/hydration/suspended-arm-value-mismatch.test.ts: 36 cases, dev and prod compile.xlink:hrefremoval, and a clone rebuilt before the arm suspended.onRecoverableErrorcount at commit, and the final DOM.4ab33b6b1, 15 of the 36 fail. The class cases pass on both, because class writes already wait until commit outside nested arms. The rebuilt-clone case passes on main itself since fix(hydration): apply a rebuilt clone's attributes without a value report #1536.e9a3a8af3, which merges main through4ab33b6b1, including fix(hydration): apply a rebuilt clone's attributes without a value report #1536 and fix(hydration): keep a suspended root's server values and report value mismatches once #1556):packages/octane/tests/hydration/passes in bothoctaneandoctane-prod(230 files, 11,893 tests).c0c3e8b35): the fulloctane-prodproject passed (614 files, 16,411 tests). The fulloctaneproject passed 19,775 tests; its 3 failures were timeouts against the tests' own 15 s limits (compiler/volar×2, onebehavior-rootcase) at a load average of about 100, and both files passed when rerun alone (207/207 and 33/33).hydration-ssr-diagnostics,vite-integration,ssr-suspense,compiler-vite-options,strong-html).benchmarks/bundle-size/run-minimal.mjs, production):hydrate-rootanddeferred-hydration: +922 raw / +258–279 gzip after the follow-up trim inc9b255d28(the first push measured +1,009 raw).cli-spa-starter,hooks-state,contextandsuspense-transition: +0.dangerouslySetInnerHTMLwarning call is now dev-guarded. Their brotli deltas move both ways by compressor noise.Risk / follow-ups
journalRepair()journals values in a root's hydrating attempt, andsave()/remember()journal structure. It doesn't cover a resolved@tryarm, because when the arm suspends the root still commits around it. The merge shares the value sites:journalRepair()calls this PR'srepaired()first.allowAttributecallsrepaired()directly, because attribute setters already journal for the root.@tryarms (the double structural report) is being stacked on this PR. It plans to foldrepaired/journalRepairand this PR'srepairs/heldWarningsinto one undo mechanism.<Hydrate>island activation keeps its capability and resumes at the cursor. It reports once, but may still show client values while pending; this was not verified. Binding-viewbindingTextrepairs silently, so it never had a report to lose.use()read inside a text hole of a reader whose server read rejected reports false structural and attribute mismatches.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core hydration rollback/settle logic in
runtime.tsfor speculative@tryarms; incorrect repair or warning timing could affect dev diagnostics and recoverable-error reporting without altering production mismatch recovery semantics for non-suspense paths.Overview
Fixes hydration mismatch reporting when a resolved
@tryarm repairs server/client text or attributes, then suspends before the attempt commits.Speculative suspense hydration now records server values before overwriting them and rolls them back if the attempt is discarded, so pending markup still shows server output instead of prematurely applied client values. Dev warnings for attributes, class, style, and kept
dangerouslySetInnerHTMLare deferred viawarnHeldHydrationMismatchuntil the attempt settles, matching text behavior and ensuringonRecoverableErrorand console diagnostics fire once on the committing retry.Nested speculative attempts merge repairs and held warnings into an outer capability through
settle/rollback. Documentation and a patch changeset describe the React-parity behavior; new hydration tests cover text, attributes, style, class, nested arms, HTML, xlink, and rebuilt clones.Reviewed by Cursor Bugbot for commit e9a3a8a. Bugbot is set up for automated code reviews on this repo. Configure here.