Repository navigation
fix(octane): drop hydration diagnostics from try bodies caught by their catch arm - #1534
Merged
Merged
Conversation
…ir catch arm A hydrating template that clones its root and then throws inside a @Try body compared that clone against whatever the server rendered there, often the server's own @catch arm, and reported a false mismatch through console.error (dev) and onRecoverableError (dev and prod). Hold hydration diagnostics while a hydrating try body renders: drop them when it throws to its catch arm, pass them to the enclosing hold otherwise, and publish when the outermost hold releases. Class mismatch warnings, which flush after the render, skip elements a caught body left detached. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 1, 2026 23:53
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)
29 other measured values are unchanged. Public-import reachability bundles (bytes)
74 other measured values are unchanged. CI job durations
Compares the CI run for
All 26 timed jobs
|
… bundles The recoverable-error publication point checked the hold's module state directly, so every bundle that retains noteRecoverableHydrationError kept the hold's counter, array and push helper (+90 raw bytes in client-only bundles such as root-static, context and the binding fixtures). Ask the current HydrationCapability to hold the diagnostic instead: the method ships only with hydration, which cuts the client-only cost to +39 raw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y-body-diagnostics
…y-body-diagnostics # Conflicts: # packages/octane/src/runtime.ts
…y-body-diagnostics
…drate-thrown-try-body-diagnostics
…drate-thrown-try-body-diagnostics
This was referenced Oct 2, 2026
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 hydrating template (
@{}) component that clones its root element and then throws inside a@trybody reported a false hydration mismatch. The clone is adopted against whatever the server rendered in its place. Often that is the server's own@catcharm, rendered because the server's body threw the same way. The client loggedOctane hydration mismatch … the client expected <i> but the server rendered <p>in development and calledonRecoverableErrorin development and production, even though the final DOM andonCaughtErrorwere correct.Hydration diagnostics are now held while a hydrating try body renders:
Changes
packages/octane/src/runtime.tsnoteRecoverableHydrationError,warnHydrationStructuralMismatch,warnHydrationValueMismatch,warnHydrationKeptServerValue) push a thunk while a hold is active.HydrationCapability.holdDiagnostics/releaseDiagnostics/renderTryBodyare methods, so client-only bundles shed them.mountTry, the initial Suspense hydration renderer, passthrough tries, the compiled<ErrorBoundary>(errorBlock) mount and re-render paths, andrenderVisibleTry. Render-phase updates drained during hydration re-render a try body that is still hydrating, so the last one can report the same false mismatch.flushTextWarningsalready does for text.docs/differences-from-react.md: one sentence in the hydration section stating the contract.octanepatch.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkpasses on every changed file and on the default staged/unstaged selection.pnpm typecheck: not run repo-wide.pnpm typecheck:files(tsrx-tsc, with the.tsrxfixture) passes on the changed files.pnpm test: not run as a whole. Before the rebase onto currentmain, the fulloctane(19,536/19,537) andoctane-prod(16,093/16,096) projects ran. The four failures were inbehavior-root.test.tsandindependent-parent.test.tsat load ~60. Both files pass 478/478 in isolation on this change, andindependent-parentalso flaked on base.targeted tests:
packages/octane/tests/hydration/try-clone-thrower.test.ts, 26 cases inoctaneandoctane-prod.console.error, noonRecoverableError, the correct final DOM, adopted<div>/<h1>/<button>hosts around the boundary, and a live click handler. They cover:@try(server catch arm and server divergence), a template-less callee,@pending(initial Suspense renderer), compiled and component<ErrorBoundary>, nested boundaries (inner catches; inner completes and outer catches; catch-less inner), a drained re-render (@tryand<ErrorBoundary>), passthrough, and a class binding adopted from the catch arm.@pending,<ErrorBoundary>, nested, drained re-render, passthrough), a body that suspends (with and without@pending), and a class mismatch on a live element.main, including fix(octane): adopt the server catch arm when a template-less use() reader rejected #1523 and fix(hydration): report a rebuilt clone's mismatch once #1533):packages/octane/tests/hydration/plusroot-error-callbacks.test.tspass in both projects (214 files, 11,316 tests). With the hold disabled, the template-less cases still fail on top of fix(octane): adopt the server catch arm when a template-less use() reader rejected #1523'srenderUnframed, which reports the missing range when the body throws an application error.Bundle bytes (
benchmarks/bundle-size/run-minimal.mjs, againstmainatf647ceff6):The second commit moves the hold check behind a
HydrationCapabilitymethod, so bundles that never hydrate no longer retain the hold's state. That cut their cost from +90 to +39 raw bytes (the first benchmark report on this PR shows the earlier numbers).Runtime: the added work is one counter increment and an array-length read per hydrating try body, plus a null check on client-only try renders. Wall-clock benchmarks were not trustworthy on the shared machine (load 40–70), so none were run.
Risk / follow-ups
handleRenderErrorwithout a hold, so it can still report. That path already warns in development about the cross-component render-phase update.use()inside a cloned template no longer reports the clone mismatch, but its catch arm is still adopted incorrectly after the clone's recovery. That is pre-existing, and separate work on server catch-arm hydration addresses it.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 and error reporting across many try/boundary render paths; behavior change is intentional but could hide real mismatches if hold/release logic is wrong on an edge path.
Overview
Fixes false hydration diagnostics when a hydrating
@try/<ErrorBoundary>body throws into its catch arm after adopting server markup (often the server’s own catch output).While a try body hydrates, dev mismatch logs and
onRecoverableErrorare held and discarded if an application error is caught locally; they still publish when the body completes, suspends, or propagates past the boundary. Hydrating try renders go throughrenderTryBodyon the main boundary paths (including Suspense retry and drained render-phase updates). Class mismatch warnings skip nodes a caught body already detached.Docs and an
octanepatch changeset document the contract.try-clone-throwerfixture + tests cover drop vs. still-report cases.Reviewed by Cursor Bugbot for commit 54c9d60. Bugbot is set up for automated code reviews on this repo. Configure here.