Repository navigation
fix(octane): render a deferred value's final attempt while a root holds its first render - #2223
Merged
trueadm merged 4 commits intoOct 23, 2026
Merged
Conversation
trueadm
marked this pull request as ready for review
October 23, 2026 17:48
trueadm
marked this pull request as draft
October 23, 2026 17:49
…ds its first render When a root with no Suspense boundary suspends on its first render, a useDeferredValue mounted with an initialValue spawned its swap, but the rollback disposed the slot and the swap was dropped. The final value never rendered until the preview fully loaded. The swap now renders the root again as a deferred pass in its host task. Its suspension keeps the original attempt's wakeable live, so whichever attempt is ready first commits, as in React 19.3 (react/react#35392). Ports the two React 19.3.0 ReactDeferredValue-test.js sibling cases into parallel-transitions.test.ts, and :407 and :526 into deferred-value.test.ts, asserting committed DOM. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
force-pushed
the
fix/deferred-root-attempt
branch
from
October 23, 2026 17:51
e4af203 to
8c6ea66
Compare
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | b0af5ed | Commit Preview URL Branch Preview URL |
Oct 23 2026, 07:07 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | b0af5ed | Commit Preview URL Branch Preview URL |
Oct 23 2026, 07:09 PM |
trueadm
marked this pull request as ready for review
October 23, 2026 18:39
…into fix/deferred-root-attempt
…into fix/deferred-root-attempt # Conflicts: # packages/octane/tests/conformance/_fixtures/parallel-transitions.tsrx # packages/octane/tests/conformance/parallel-transitions.test.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Duplicate deferred retries drop original wakeable
- Added per-owner deduplication in runDeferredSwaps using a Set so that when multiple disposed useDeferredValue slots share the same root owner, only the first calls owner.retry(true), preventing subsequent retries from invalidating the first attempt's generation and orphaning the original wakeable's ping.
Or push these changes by commenting:
@cursor push d7b9b98eeb
Preview (d7b9b98eeb)
diff --git a/packages/octane/src/runtime/engine.ts b/packages/octane/src/runtime/engine.ts
--- a/packages/octane/src/runtime/engine.ts
+++ b/packages/octane/src/runtime/engine.ts
@@ -5031,6 +5031,7 @@
* is queued (spawnDeferredSwap). Async act() keeps draining while it is set.
*/
let DEFERRED_SWAPS: Array<DeferredSlot<any>> | null = null;
+let DEFERRED_RETRIED: Set<RootRenderOwner> | undefined;
/**
* Schedule the deferred current→next swap in a later host task (#1864). A
@@ -5071,6 +5072,7 @@
for (let i = 0; i < slots.length; i++) swapDeferredValue(slots[i]);
} finally {
TRANSITION_TASK_ACTIVE = false;
+ DEFERRED_RETRIED = undefined;
}
}
@@ -5087,9 +5089,12 @@
if (
owner !== undefined &&
owner.wakeable !== null &&
- (owner.current === null || owner.current.disposed)
- )
+ (owner.current === null || owner.current.disposed) &&
+ !(DEFERRED_RETRIED ??= new Set()).has(owner)
+ ) {
+ DEFERRED_RETRIED.add(owner);
owner.retry(true);
+ }
return;
}
if (Object.is(s.value, s.next)) return;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit b7c7baa. Configure here.
Each disposed useDeferredValue slot from a rolled-back root render called owner.retry(true) on its own. With two such hooks, the second deferred attempt rolled back the first and unioned only its wakeable, so the original attempt's data no longer retried the root and the initial values never committed. Collect held roots and retry each once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 23, 2026
…l-transitions-main Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 of 9 tasks
trueadm
added a commit
that referenced
this pull request
Oct 23, 2026
* fix(runtime): scope optimistic cleanup to transition batches * fix(runtime): keep optimistic reverts out of cross-render diagnosis A transition batch can finish while a Suspense boundary renders: an urgent update that supersedes a held transition releases the hold inside the boundary's render (releaseHeldTransition -> releaseTransitionHookHolder -> finishTransitionHookBatch). The batch-scoped useOptimistic revert then scheduled its block while another component was on the stack, so dev logged "Cannot update a component while rendering a different component" and the block was flagged as a cross-render update. The global listener this replaced ran under the publish-depth guard; schedule the revert under it again via scheduleHookPublication. Also update the TRANSITION_PENDING_COUNT comment: optimistic lifetimes no longer subscribe to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(octane): commit unrelated transitions independently Re-lands #2165 on main. It merged into `next` on 2026-10-20, after #2103 had already integrated `next` into `main`, and `next` was then deleted, so the change never reached `main`. This is the #2165 squash commit (2af686e) without its useOptimistic fix: #2218 scopes optimistic reverts to their transition batch, so this change builds on it rather than adding a second mechanism. React 19.3 renders each transition lane on its own, so a suspended transition no longer holds back an unrelated one: - The reveal barrier groups held boundaries that hold a common batch (stagedRevealGroup), so one transition's boundaries still reveal together while unrelated groups commit on their own, each once per flush. - A held boundary still on screen retries its batches when any thenable it suspended on settles, keeping the fresher thenable's resume and fallback timeout. Refs #2053. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(octane): give boundaries without a batch hold their own reveal group stagedRevealGroup put every held boundary without a batch hold into every group. That one rule covered three different cases: a transition that folded no hook work (`root.render` in startTransition), a holder released during its retry, and members of a view-transition-deferred reveal. So unrelated groups were pulled together: a hook transition waited behind an unrelated root.render transition, and a deferred group could be absorbed into another flush. Boundaries without a batch hold now form one group of their own, the barrier before parallel transitions, and never join a batch's group. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(octane): render a deferred value's final attempt while a root holds its first render (#2223) * fix(octane): render a deferred value's final attempt while a root holds its first render When a root with no Suspense boundary suspends on its first render, a useDeferredValue mounted with an initialValue spawned its swap, but the rollback disposed the slot and the swap was dropped. The final value never rendered until the preview fully loaded. The swap now renders the root again as a deferred pass in its host task. Its suspension keeps the original attempt's wakeable live, so whichever attempt is ready first commits, as in React 19.3 (react/react#35392). Ports the two React 19.3.0 ReactDeferredValue-test.js sibling cases into parallel-transitions.test.ts, and :407 and :526 into deferred-value.test.ts, asserting committed DOM. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(octane): retry a held root's deferred attempt once per swap task Each disposed useDeferredValue slot from a rolled-back root render called owner.retry(true) on its own. With two such hooks, the second deferred attempt rolled back the first and unioned only its wakeable, so the original attempt's data no longer retried the root and the initial values never committed. Collect held roots and retry each once. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * test(octane): reveal a parked hydration boundary while an unrelated transition holds The sibling case from #2193 expected Gate's ready reveal to wait for Later's unrelated transition, the global barrier from before parallel transitions. Gate's root.render transition and Later's setLater transition are separate, so Gate now reveals once its own data lands while Later keeps holding; the primary, listener and event assertions run at that point. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: dannyward630 <[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
feat/parallel-transitions-main, the re-land of feat(octane): commit unrelated transitions independently #2165 on top of fix(runtime): scope optimistic reverts to transition batches #2218). This PR's base is that branch, so its diff shows only this change.ReactDeferredValue-test.jscases that React 19.3.0 added with parallel transitions ([flags] AddenableParallelTransitionsreact/react#35392, enabled by [flags] Enable enableParallelTransitions react/react#37290). In both, a root with no Suspense boundary holds its first render onuseDeferredValue('Final', 'Loading...')while the initial value and the final value each wait on a sibling.:407(no Suspense boundary) and:526(finish the original task if it loads first). Both are ported now.Why
@try/@pendingboundary, Octane already switched to the final value (:484). Without one, the root rolls back its whole first attempt. That disposes the slot that spawned the deferred swap, andswapDeferredValuedropped swaps for disposed slots. Root suspension without a boundary has been supported since Retain and retry a suspended root when no Suspense boundary is present #821, so the old "N/A: requires a parked root render" note was stale.mainas well.Changes
swapDeferredValue(runtime/engine.ts): when the slot's Block is disposed and its root is still waiting for its first commit, it callsowner.retry(true)instead of returning. The condition isowner.wakeable !== nullandowner.currentis null or disposed; a transition mount leaves a disposed root Block between attempts.RootRenderOwner.retry(deferred?)andrenderResolved(…, deferred): a deferred retry mounts directly at transition priority withpendingDeferredset. AuseDeferredValuemounting inside that pass adopts its final value through the existing anti-waterfall rule.suspendRootRender(runtime/render.ts): a suspension inside a deferred pass also wakes on the wakeable of the attempt that spawned it. Either attempt can then commit first. The value is read before the rollback, because disposing the root Block clears it.conformance/parallel-transitions.test.ts(fixtureDeferredSiblings);:407,:526, and a transition-mount variant of:407inconformance/deferred-value.test.ts;docs/react-parity-coverage.mdis regenerated.Validation
pnpm format:check: not run; changed files were formatted withpnpm format:files.pnpm typecheck: not run.pnpm typecheck:filespasses on the three changed runtime files.pnpm test: not run locally. CI doesn't run on this PR while its base isfeat/parallel-transitions-main:ci.ymlfilters PRs tomain,nextandjon/update-bindings-*. CI runs once it targetsmain.parallel-transitions.test.tsanddeferred-value.test.tspass inoctaneandoctane-prod(54/54).:407, and the transition-mount case fail in both projects.:526and the 19.3.0 "original sibling loads first" case fail (checked onmain), so those two pin the neighbouring behavior.pnpm react-parity:validate: metadata current.pnpm sync: no generated changes.perf-review: this PR's diff scans clean (git diff origin/feat/parallel-transitions-main...HEAD | node scripts/perf-review-scan.mjs --diff -).swapDeferredValueruns only for a disposed slot (cold).pendingDeferredis a declaredBlockImplboolean set once per root mount, so there is no shape change. The retry closure is still one perroot.render().suspendRootRenderadds one field read, plus oneresumeOnSettleonly for a deferred pass. No compiled output, imports, or reachability changes.concise-code: src +27 −5 (all runtime). No new files or exports outside test fixtures.Risk / follow-ups
useDeferredValue(value, initialValue)below no boundary, Octane still waits for the preview. React would render the final value too. That path goes through the root transition-holder machinery and needs its own change.main; this branch will need a rebase onto feat(octane): commit unrelated transitions independently #2222's new head.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
High Risk
Touches root suspension, deferred-value scheduling, and commit/retry ordering in the reconciler—behavior that affects first paint and transition mounts without a Suspense boundary.
Overview
Aligns
useDeferredValuewith React when a root has no Suspense boundary: a suspended first render on the initial value now also schedules a deferred final-value attempt, and whichever attempt’s data is ready first commits (including transition mounts and dual-hook roots).Runtime:
swapDeferredValueno longer drops swaps when the spawning block was rolled back on root suspend—it returns the held root sorunDeferredSwapscan callretry(true)once per root. Rootretry(deferred)/renderResolvedmount deferred passes withpendingDeferred, andsuspendRootRenderregisters wakeables for both the current deferred pass and the spawning attempt.Conformance: Ports upstream
ReactDeferredValue-test.jscases previously marked N/A (:407,:526) plus React 19.3 sibling-resolution cases indeferred-value.test.tsandparallel-transitions.test.ts; ledger and parity docs move those entries to covered.Reviewed by Cursor Bugbot for commit b0af5ed. Bugbot is set up for automated code reviews on this repo. Configure here.