Repository navigation
fix(octane): pace ready query results and finish backlog investigation - #1983
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 6e58afc | Commit Preview URL Branch Preview URL |
Oct 10 2026, 09:28 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 6e58afc | Commit Preview URL Branch Preview URL |
Oct 10 2026, 09:31 PM |
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
54 other measured values are unchanged. Public-import reachability bundles (bytes)
109 other measured values are unchanged. |
trueadm
left a comment
There was a problem hiding this comment.
Review
The pacing itself looks right. receivePromiseValue re-enters currentEntry(attempt) after every wait, carries nothing from the stale entry across it, and reuses the existing budget without adding a queue or fields. The replace/dispose regressions cover the lease. The investigation is thorough. Two things block merge, though. Both come from the change reaching further than bursts.
Blocking
1. CI is red because of this change. test shard (Node 24, 1/4) has 16 failures in packages/octane/tests/behavior-root.test.ts: 4 tests × dev/prod × octane/octane-prod. Main is green at the base (c82354bf84). Fail-fast cancelled shards 2/4 and 4/4; they did not fail. 4/4 had already passed 664/664 files, but 2/4 never reported, so there may be more failures. I reproduced the same 8 failures locally on 0760168 with vitest run --project octane packages/octane/tests/behavior-root.test.ts.
The cause: yieldForHostBudget fixes started at the first check in a host task and keeps it until the sentinel task runs. These tests only await microtasks (settle() is 4 × await Promise.resolve()), and between those awaits they compile and SSR fixtures synchronously. Once any earlier check has opened the window, the next query result moves to the sentinel task, which settle() never reaches.
- adopts and switches @Try arms… fails even when run alone.
first,secondandrecoveredpublish. Then the secondfixture()compile runs in the same task, andfourthis deferred (L9811). - builds a @Try region inside an arm… passes alone but fails in the full file, because an earlier test opened the window. The outcome now depends on test order.
- keeps a server-resolved @Try arm…: the query resolves before the synchronous
renderToString, yet the server still renders@pending. It fails at L10119 in the file run and at L10130 alone. - hydrates a binding view's settled @Try arms…: in the
readycase the server renders@pending, then the client hydratesreadyand replaces the server node (L9923). Theerrorcase passes because rejections aren't paced.
2. act() no longer drains query results. The async drain in act loops only while hasPendingWork() || DEFERRED_SWAPS !== null || transitionTask !== 0. A result waiting on the budget sentinel doesn't count as pending work. Probe setup: 12 query resources, each subscriber adds 2 ms to a mocked performance.now and bumps a useState, and all 12 are resolved inside await act(async () => …).
- base
requests.ts: 12/12 published and rendered afteract - this PR: 6/12
Stream pacing already had this gap. This PR extends it to every promise query, which app tests use far more often. Suggested fix: export a cheap check from host-budget.ts that says a budget wait is pending (for example sentinel !== undefined), add it to both hadWork sites, and add a regression in signal-task.test.ts.
Contract and docs
3. The behavior change is broader than "large bursts". A single successful query result can now arrive one host task after its promise settles. That happens whenever the current task has already used about 5 ms since any budget check: a compile, hydration, a long render, another producer, or a previous test. I'd keep that. It is closer to React, where Suspense pings go through Scheduler tasks that act() drains. But it should be stated plainly:
- In
differences-from-react.mdL1423 and the changeset, say:- a lone result can also wait one host task;
- a synchronous
renderToStringrun right after the promise resolves can still render pending; - tests should use
act()(once #2 is fixed) or a host-task wait instead of counting microtasks.
- Then update the four
behavior-roottests to wait the right way, with the same final-state assertions. That fixes an assumption that is now wrong; it doesn't weaken the tests.
4. Rejections stay unpaced (failAttempt). In one task, a failing query shows @catch immediately, while a sibling success that settled earlier waits for the sentinel. The hydration test above shows exactly that split. Is there a reason not to pace rejections too? A burst of rejections with expensive @catch subscribers produces the same long checkpoint. If they stay unpaced on purpose, say so in the differences doc, not only in investigation.md.
Minor
signals-ready-process.test.tsonly driveskind: 'stream'andderived$producers, so it guards the existing stream budget, notreceivePromiseValue. Keeping it to close out #1864 is fine. The PR body just reads as if it covers the query fix.differences-from-react.mdhas two lines that weren't rewrapped ("…so many producers do" and "…UseuseLayoutEffectwhen the"), and so doesinvestigation.md("unthrottled control. Use--work-ms=0…").
Also checked and fine: the benchmark-only policy swap (an esbuild onLoad rewrite guarded by assert.match) never reaches shipped code; the generated scheduling.md copies match .rulesync; and the bench report shows no byte or work-counter changes.
Summary
One hundred independent query promises settling together could still spend an entire ~234 ms checkpoint delivering subscribers, even though their component renders coalesced. Publish successful query results through the existing shared host budget, rechecking ownership after each wait. In the paired production Chromium probe, the longest checkpoint falls to ~8 ms and all 15 later keystrokes run before completion.
This also completes the remaining investigation work in #1864: an externally supervised infinite-producer regression; cold/ready, small/large, multi-root and fragmented-reader browser cases; deferred/Action React controls; frame and main-thread traces; allocation/retention observations; count/time/combined budget comparisons; and waiting-island selection, IME and user-activation checks. See the measurements and policy decisions.
Changes
act()drains include the existing budget sentinel, so they await paced query/stream publications and their resulting UI. Cover synchronous and asynchronous callbacks.Validation
pnpm typecheck:files;pnpm sync.act()for query publication; all DOM, identity, error, and disposal assertions remain. All 698 cases pass with the updated waits.act()regression: all 12 dev/prod cases fail before the drain fix (only 3–6 of 12 values arrive) and pass after it. The broaderact()/scheduler/reader/effect/behavior-root rerun passes 932 tests.root-static,hooks-state, andserver-renderreachability controls: identical raw/gzip/brotli sizes on current main and the candidate. Query fixture delta: +86 raw / +12 gzip bytes in the paired probe.6e58afcb36: all test shards, production typechecking, lint, React parity, browser/Node/website integration, example apps, package validation, compatibility, and provenance passed. Bugbot completed without findings; all 32 checks passed.perf-review: scan reports 0 candidates. Hot path:receivePromiseValue, once per successful query result plus admission retries. No new record fields, DOM work, task poster, or compiler output. One conditional retry closure per exhausted-budget wait; publication still uses the existing native-producer batch. Whole-page allocation sampling and commit/effect counts quantify the cost. The additional budget-sentinel check runs only in the two asynchronousact()drains and adds no state, allocation, or per-render work. The root/state/server bundle controls remain byte-identical. No unresolved must-fix finding.concise-code: shipped/runtime source +34 −11. Reusing the existing sentinel avoids a second pending-work counter and its cancellation bookkeeping. New files are the externally supervised worker and test, the private benchmark declaration bridge, the investigation report, and the required changeset. Extending the existing budget avoids a second queue or public policy option; extending the existing browser server and form fixture avoids separate harnesses. A promise-only watchdog cannot escape starvation.Risk / follow-ups
act(), grows by 39 raw / 76 gzip / 121 Brotli bytes. The other 54 application-bundle measurements are unchanged; 109 public-import measurements are unchanged and hydrate-frame compression decreases slightly. The new sentinel check is confined to awaitedact()drains.octane-jsx-jsbenchagainst basec82354bf84and this head with the same locked dependencies produces byte-identical JavaScript, HTML, and client-build metadata. The JavaScript SHA-256 is6bf018fb2a14e84fa72b9aa24e13a9cfa4cd6baedfb38a76886fc86ec2b2cc94. Together with unchanged operation/DOM counters, this is evidence against attributing that timing delta to changed application code; it is not a claim that the measured delta was zero.Refs #1864.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core scheduler/query publication timing and
act()drain semantics; apps/tests that assumed immediate query publication or microtask settling may need updates, though rejections and retained reads are unchanged.Overview
Ready query successes now share the same ~5 ms host budget as streams, so large bursts of independent promise completions can yield between publications instead of running all subscriber/render work in one microtask checkpoint.
receivePromiseValuecallsyieldForHostBudget, retries after a host task, and re-checks request ownership; rejections stay on the existing prompt path.Awaited
act()now treats a pending budget sentinel as work to drain (hasPendingHostBudget), and tests/docs call out that sync SSR right after resolve may still see pending and that microtask-count settling is unreliable.#1864 investigation is wrapped up in-repo: expanded Chromium backlog runner (queries, RPC/renderer readers, deferred, matrix/policy builds),
investigation.mdwith measurements, scheduling skill copies anddocs/differences-from-react.mdupdated (Action bodies unpaced, passive drain-before-render, query pacing edge cases). Regression coverage adds signal-task pacing/disposal tests, an external-process infinite-producer watchdog, browser scheduler-backlogs scenarios, and a waiting independent-island form test (selection/IME/user activation).Reviewed by Cursor Bugbot for commit 6e58afc. Bugbot is set up for automated code reviews on this repo. Configure here.