Repository navigation
fix(octane): render transition-priority work in a later task - #1873
Conversation
Transition renders were flushed on a microtask, like urgent ones, so every ready continuation paid for its own render and commit inside one microtask checkpoint. A hundred synchronous useActionState dispatches committed 101 times where React 19 commits twice, and the browser could neither paint nor deliver input until the last one finished (#1864, step 2, G1). Transition renders scheduled outside a render or flush now wait in a TRANSITION_QUEUE for a host task of their own (postHostTask), as React renders a transition lane in a Scheduler task. That covers startTransition updates, Action results, transitions started after an await, and the updates of the async-Action window. The microtask flush never drains the queue; the task, flushSync and act() do. An urgent update to a waiting block moves it onto the microtask flush, and the pending cues (useTransition and useActionState raising isPending, useOptimistic showing a value) keep the microtask flush so they commit before the work they announce. A transition's pending-count release waits for the task's flush (afterTransitionFlush), and its retained FLUSHED_TRANSITION_UPDATES survive an urgent flush that runs first, so a suspending transition still holds. Work scheduled while the task (or the useDeferredValue swap task) runs joins its own flush, and a view-transition-wrapped Suspense resume adopts the queue. The task path is a driver installed with the first transition, so applications that never start one keep the old scheduler shape. The island activation gate now uses the shared postHostTask. differences-from-react.md §Actions and §Scheduler, the website's Forms section, and the transition-hooks benchmark harness (which now waits for the host task) describe the new timing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tore maybeFlushDiscrete decided between the view-transition flush and flushSync from QUEUE alone, so a transition-only controlled input (onInput calling startTransition) waiting for its task fell to flushSync and skipped startViewTransition. Adopt the waiting transitions first, as before #1864 step 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Resume adopt releases followups too early
- Saved and cleared TRANSITION_FOLLOWUPS before adoptTransitionQueue in wrapResume, then dispatched them at each exit path's correct flush point: before synchronous flushWork/vtFlush, after vtScheduleQueuedWork for the !vtNativeAvailable path, and re-injected into TRANSITION_FOLLOWUPS for the promise-deferred path's recursive wrapResume to handle.
Or push these changes by commenting:
@cursor push df5bd81b14
Preview (df5bd81b14)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -7051,6 +7051,13 @@
// then include every sibling update those passives scheduled. Transitions
// waiting for their task join too, so one view transition captures them.
const passivesSettled = vtDrainPassivesBeforeCapture();
+ // adoptTransitionQueue dispatches TRANSITION_FOLLOWUPS as microtasks
+ // under the contract that the caller flushes synchronously in the same
+ // turn. wrapResume may wait on in-flight handles or return without
+ // flushing, so save and clear followups here, then dispatch them at
+ // each exit path's flush point.
+ const savedFollowups = TRANSITION_FOLLOWUPS;
+ TRANSITION_FOLLOWUPS = null;
adoptTransitionQueue();
const capture = VT_CAPTURE;
const resumed = getBlocks?.() ?? [];
@@ -7061,6 +7068,8 @@
// can touch further owners, so only that fallback interrupts all scopes.
if (passivesSettled) vtInterruptOwners(owners);
else vtInterrupt();
+ if (savedFollowups !== null)
+ for (let i = 0; i < savedFollowups.length; i++) queueMicrotask(savedFollowups[i]);
work();
flushWork();
return true;
@@ -7068,7 +7077,11 @@
const handles = vtActiveHandles(owners);
if (capture !== null || handles.size > 0) {
vtWaitForHandles(handles, owners);
+ const deferred = savedFollowups;
const resume = (): void => {
+ // Re-inject so the recursive wrapResume's adopt dispatches
+ // them at the right point before its own flush.
+ if (deferred !== null) (TRANSITION_FOLLOWUPS ??= []).push(...deferred);
if (!driver.wrapResume(work, getBlocks)) work();
};
const waits: Promise<void>[] = [];
@@ -7079,9 +7092,14 @@
}
if (!vtNativeAvailable(owners)) {
// The caller commits only the resume; adopted transitions still need a flush.
+ // Queue followups after the scheduled flush microtask so they run after it.
vtScheduleQueuedWork();
+ if (savedFollowups !== null)
+ for (let i = 0; i < savedFollowups.length; i++) queueMicrotask(savedFollowups[i]);
return false;
}
+ if (savedFollowups !== null)
+ for (let i = 0; i < savedFollowups.length; i++) queueMicrotask(savedFollowups[i]);
vtFlush(
() => {
work();You can send follow-ups to the cloud agent here.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 56aabcc | Commit Preview URL Branch Preview URL |
Oct 08 2026, 07:32 AM |
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
9 other measured values are unchanged. Public-import reachability bundles (bytes)
35 other measured values are unchanged. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 56aabcc | Commit Preview URL Branch Preview URL |
Oct 08 2026, 07:34 AM |
wrapResume adopted the transition queue before it knew whether it would drain: on the paths that wait for an in-flight view transition or fall back to an unwrapped resume, that retired the posted task and released the transition's follow-ups (isPending's falling edge, form resets) before its render. Owners now include the waiting blocks without adopting them; only the urgent-sibling drain and the vtFlush update callback adopt, and the other paths leave the queue to its own task. Also move the website a11y baseline's /docs/core-apis table selector from nth-child(204) to nth-child(205): the new Forms paragraph shifts that table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shard 1/4 fails its byte budgets until #1874 merges, and fail-fast then cancels shards 2-4. This commit only lets those shards report; it is reverted before merge, and the raise lands through #1874. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The head commit temporarily carries #1874's budgets. Without them, shard 1/4 fails its byte budget and fail-fast cancels shards 2–4, so their tests never report. Expect "Check that byte budget raises land alone" to fail while that commit is here. I'll revert it once the shards report; the raise itself lands through #1874, which still merges immediately before this PR. |
…task Router updates are transitions, which now commit in a later task (#1864), so a synchronous revalidation loader coalesced "loading" and "idle" into one render and the boundary never saw the loading -> idle edge it resets on, as under React's Scheduler. Keep the loader pending across tasks so the loading state commits, and assert the caught error persists until the revalidation completes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test shards reported on a17a35a (all four passed with identical code). The raise lands through #1874, which merges immediately before this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The temporary budget commit is reverted in f6e2990. While it was here, a17a35a ran every test shard (1/4–4/4), the React parity shards, the website suite, the heavy integration lanes and the benchmark report, and all of them passed. The code is identical now.
|
…1874) Budget-only raise for #1873 (#1864 step 2), which renders transition-priority work in a posted host task. Every budget moves to #1873's measured bytes + 32. Co-authored-by: Claude Opus 5.5 <[email protected]>
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: Upgrade leaves transition queue leftovers
- upgradeTransitionBlock now splices the block out of TRANSITION_QUEUE on upgrade and retires the transition task (flushing followups) when the queue becomes empty, preventing leftover entries from corrupting queueAllTransition and delaying isPending.
Or push these changes by commenting:
@cursor push a1f1e0a1f4
Preview (a1f1e0a1f4)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -7665,18 +7665,16 @@
/** An urgent update or pending cue moves a waiting block onto the microtask flush. */
function upgradeTransitionBlock(block: Block, mode: 'urgent' | 'transition', cue?: boolean): void {
- if (
- (mode !== 'urgent' && !cue) ||
- block.pendingMode !== 'transition' ||
- syncFlush ||
- !TRANSITION_QUEUE.includes(block)
- )
- return;
+ if ((mode !== 'urgent' && !cue) || block.pendingMode !== 'transition' || syncFlush) return;
+ const idx = TRANSITION_QUEUE.indexOf(block);
+ if (idx === -1) return;
+ TRANSITION_QUEUE.splice(idx, 1);
QUEUE.push(block);
if (!scheduled) {
scheduled = true;
queueMicrotask(flush);
}
+ if (TRANSITION_QUEUE.length === 0) adoptTransitionQueue();
}
function scheduleTransitionTask(): void {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 85cbe3f. Configure here.
upgradeTransitionBlock copied a waiting block onto QUEUE but left it in TRANSITION_QUEUE. Once that render committed, the stale entry was adopted with a null pendingMode, so the task's flush no longer looked all-transition and lost its ViewTransition wrap, and the transition's follow-ups (isPending's falling edge) stayed on a task with nothing left to do. Splice the block out, and when the queue empties, retire the task so the follow-ups run after the microtask flush that now renders the work. The change shrinks brotli for suspense-transition and the bindings app, so their budgets ratchet down with --write-budgets (lowerings only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sition test (#1902) "commits without animation when a pre-render passive adds urgent sibling work" relies on a passive effect from a sync commit still being pending when the transition's host task (#1873) starts rendering. In the test, that passive is drained at the next animation frame, which then posts to the runtime's long-lived post-paint port. When jsdom's frame timer comes due before the transition task runs, as it can on a loaded CI worker, the passive drains first and the transition animates. The test's capture mock never runs the update, so the left scope stays 'initial', and `vi.waitFor` timed out in octane-prod on #1893. The test now fakes setTimeout and requestAnimationFrame, so no frame and no fallback timer can drain the passive early. It waits for the transition with a host task posted after the runtime's, not by polling, because `vi.waitFor` would advance the fake timers. The host-task `nextTask()` helper moves to tests/_helpers.ts. It replaces the local copies in view-transition.test.ts and view-transition-matching.test.ts. #1875 already made the matching tests wait for the native transition start. Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
Step 2 (G1) of #1864. A flush that holds only transition-priority work now runs in a posted host task (
postHostTask), not inqueueMicrotask(flush). A backlog of ready Action results, or transitions started after eachawait, therefore renders once, after the browser has had a chance to paint and deliver input.mainuseActionStatedispatches0P, 1P … 99P, 100)0P,100)Merge order: the budget-only #1874 has to land immediately before this one. Until it does, shard 1/4 and the PR bench fail their byte budgets. See "Bundle" below.
Why
Transition renders were flushed on a microtask, exactly like urgent ones. Every ready continuation in a burst paid for its own render and commit inside one microtask checkpoint, so nothing could paint and no input could be delivered until the last one finished. React renders a transition lane in a Scheduler task. The investigation comment on #1864 proposed this as G1, and the progress comment listed the design points that are settled below.
Changes
packages/octane/src/runtime.ts:TRANSITION_QUEUEand its task. A transition-modescheduleRenderfrom outside a render or flush pushes the block toTRANSITION_QUEUEand posts one task. The task adopts the queue intoQUEUEand runs the ordinaryflush().useDeferredValueswap task.flushSync, syncact(), a VT-wrapped Suspense resume, the controlled-input restore inmaybeFlushDiscrete) retires the posted task by id. Transitions scheduled after that point post a fresh task rather than joining one queued before input that arrived in between.TRANSITION_QUEUE, so transition blocks wait for their task even while urgent work flushes. An urgent update to a waiting block moves it onto the microtask flush (upgradeTransitionBlock). The existing urgent-ancestor machinery (UrgentTransitionRender) still renders a waiting child's committed cells under an urgent parent.useTransitionanduseActionStateraisingisPending, anduseOptimisticadding a value, pass acueargument toscheduleRender. They keep the microtask flush at their computed priority, so the cue commits before the work it announces, as React's urgent cue does.queueMicrotasktoafterTransitionFlush, which runs it as a microtask after the task's flush. That step coverstickTransitionCount(-1),finishTransitionHookBatch, form resets anduseFormStatus. Without the move,isPendingwould fall before the transition rendered.flushWorkkeepsFLUSHED_TRANSITION_UPDATESwhile transition renders still wait. Otherwise a cue flush that runs first would clear them, and the deferred render could no longer hold when it suspended.scheduleRender,makeRoot's transition render, and the native signal transition flush now use the task.flush()re-entrancy backstop, theflushSynctail, the deferred-layout re-arm,endDetachedBoundaryRender, the first-render commit, and the hydration commit stay urgent. They re-arm work that is already inQUEUE.vtScheduleQueuedWorkre-arms work that is already inQUEUE; it is also used to flush adopted transitions on the resume fallback path.flushSync, or a commit callback are already transition-tagged, so they now also wait for a task. React schedules those updates (DefaultLane) in a Scheduler task too, so this moves them toward React. Narrowing the window would need AsyncContext. Documented.act()andhasPendingWork(). Asyncact()keeps draining while a transition task is posted.hasPendingWork()now counts waiting transition renders, whichflushSyncdrains synchronously, so testing-library'ssettleSyncstill reaches quiescence.TRANSITION_TASK_DRIVERinstalled byensureTransitionSwapDriver. An application that never starts a transition pays only the checks inscheduleRender,flushSync,flushWorkandmaybeFlushDiscrete.packages/octane/src/hydration/independent-island.ts: the privatepostActivationTaskis replaced by the sharedpostHostTask. The island bootstrap chunk is neutral: esbuild minified 23,991 → 23,996 raw, gzip 8,693 → 8,693.Contract and docs:
docs/differences-from-react.md:websitecore APIs, Forms section: one sentence on backlog rendering.Tests:
transition-flush-task.test.ts(jsdom, pre-armedMessageChannelmarker):['0', '0P', 'task', '100'];Promise.resolveresults give the same;['0', '0P', 'task', '1100'];['0', '0P', 'task', '3'];act()andflushSyncdrain it;startTransitionafterawaitgive['0', 'task', '100'];flushSyncand syncact()drain;['button pending', 'task', 'panel 1', 'button idle'];useOptimisticshows its value at once and its clear commits with the settled value;startViewTransition.browser/action-backlog(octane-events-browser): the same fixture runs on Octane and React with Chromium Event Timing, asserting one result render and a release latency under half the backlog's cost.conformance/async-actions.test.tsnow asserts the pre-task state, then waits a task;layout-effect-update-priority.test.ts;view-transition.test.ts: the delegated click transition reachesstartViewTransitionafter a task;view-transition-scoped-effects.test.ts.benchmarks/transition-hooks:quiescenow also waits for a host task;cycle_runtime_objectsone-time allowance goes 1 → 3.mainalready measured 706 against the 705 ceiling, with two lazily installed driver records (swap and root); the task driver is the third.Validation
main:FLUSHED_TRANSITION_UPDATESretention is reverted;maybeFlushDiscreteadopt;main.octane: 129 files / 2,559 tests (transition, action, Suspense, scheduler, hooks, effects, events, roots);octane: 169 files / 3,712 tests (controlled, event, form, input, select, transition, view-transition);octane-prod: 9 files / 163 tests;octane-signals: 6 files / 110 tests;octane-profiledevtools transitions;testing-library: 12 files / 69 tests;octane-events-browser(action-backlog, continuous-actions, form-actions): 3 files / 42 tests.pnpm typecheck:fileson every changed source, test and fixture.pnpm format:files;pnpm syncclean.pnpm test,pnpm typecheck,pnpm format:check: left to CI, per the local-load rule.Performance audit
pair.mjs --work-only,mainvs this branch): everycalls_*anddom_*counter is identical foroctane-tsrxandoctane-jsx.scheduleRendergained no call: the transition path sits behindmode === 'transition'and an optional driver.node benchmarks/bench.mjs --ratios transition-hooks: 42 of 42 guards pass, and the render-sequence, DOM, hold/release and bail controls are unchanged. Held cycles add oneMessageChanneland its handler per cycle, which ispostHostTaskin Node (640/704 functions, 834/961 constructors).run-minimal.mjs,main→ this branch:cli-spa-starter+189 / +80,root-static+189 / +68,hydrate-frame+189 / +45);suspense-transition, base-ui, radix, apollo-client);run.mjsframework gzip: octane-tsrx +88, octane-jsx +106, todomvc +86, chat-stream +72, weather +92, bindings +378; ceiling +415.Perf review (
node scripts/perf-review-scan.mjs, 6 candidates)Hot path touched:
scheduleRender, on every update. It gains one string compare plus an optional-chained driver call, only whenmode === 'transition', and aTRANSITION_QUEUE.lengthcheck on the already-pending path. It allocates nothing, and the work counters are identical.runtime.tsscheduleTransitionTaskpostHostTask's channel in Node. This is per burst, not per update.Dismissed candidates:
upgradeTransitionBlockqueueMicrotask(flush)[microtask-hop]: guarded byscheduled, so one arm per flush, and it moves already-queued work.adoptTransitionQueue/afterTransitionFlushqueueMicrotask[microtask-hop]: these replace the existing per-transition finish microtask one for one and render nothing themselves.scheduleRender(block, false, …)×3 [schedule-render]: existing call sites that gained thecueargument.Risk / follow-ups
useTransition. When the component that raisesisPendingalso holds the transition's update (the canonical tabs example), both render together in the microtask flush, as onmain. Octane keeps one live tree and the cells are already written. React parity there needs the transition's cells staged until the task, as async Actions already do. Documented in §Scheduler.mainbehavior). React would restore the old value until the transition commits.drainQueueends with the native coordinator's flush. Step 3 (G2a) owns signal publication coalescing.act(). Binding suites that pin that timing will show up in CI.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Changes core scheduler commit timing for transitions, Actions, flushSync/act, and view transitions; tests that assumed microtask-only commits must await a host task.
Overview
Transition-priority renders now flush in a deferred host task (
scheduler.postTask→MessageChannel→setTimeout) instead of the urgent microtask checkpoint, matching React’s transition lane scheduling (#1864).The runtime adds a
TRANSITION_QUEUEand lazily installed task driver: transition work scheduled outside an active flush is queued and adopted into a singleflush()when the posted task runs, so bursts of readyuseActionStateresults or post-awaitstartTransitionupdates commit once rather than once per microtask hop. Pending cues (useTransition/useActionStateisPending,useOptimistic) still use the microtask path via acueflag onscheduleRender; urgent updates can upgrade waiting blocks off the transition queue.flushSync,act(), view-transition resume, and controlled-input restore paths adopt the queue; transition finish hooks move toafterTransitionFlush.independent-islandactivation posting is deduplicated onto sharedpostHostTask. Docs, website copy, transition-hooks benchmark quiesce logic, bundle budget baselines, and broad tests (including browser Event Timing for action backlog) reflect the new timing.Reviewed by Cursor Bugbot for commit 56aabcc. Bugbot is set up for automated code reviews on this repo. Configure here.