Skip to content

fix(octane): keep pending readers attached to accepted work - #1775

Merged
domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-pending-wakeup
Oct 6, 2026
Merged

domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-pending-wakeup

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1763. When an accepted pending derived computation replaces earlier work, transfer its live waiter to the authoritative signal and wake readers of the displaced waiter. Re-evaluate an accepted pending view if its waiter settled or a dependency invalidated it before acceptance. Notify moved consumers and invalidate stale witnesses so readers cannot stay attached to an obsolete pending result.

The equality fast path retains the snapshot only while both waiters are live and the dependency and owner provenance match. Thenables are not assumed to represent the same underlying promise.

Validation

  • Integrated landed fix(octane): handle hydration mismatches like React 19 (boundary/root client-render fallback) #1784 (91079dd) and its full prerequisite stack from main 1de873c. graph.ts merged cleanly; no hydration workaround was added.
  • Current branch local waiter, pending-promotion, graph and signal-owner hydration tests: 313/313 dev, 617/617 prod/Strong. Thirteen current-main hydration and Suspense recovery suites: 404/404 dev and 404/404 prod. Total: 1,738 passed.
  • The tests cover new recovery restarts, stale deferred work, captured errors, suspended rebuilds, pending queries, stream signal controls and ownership. Original promotion/equal-waiter/dependency regressions failed before the fix.
  • The current deferred-hydration budget passes: 237,508 raw / 75,733 gzip / 65,190 Brotli.
  • Sync generated no additional files; staged and unstaged diff checks pass. Local sync used the cached pnpm 11 fallback; full pinned workspace checks are CI-only.
  • Full GitHub CI passed on c75ab59 after the landed hydration integration: all Node 24 test shards, React parity, benchmarks, typecheck, lint, examples, browser and package/eval integrations. No failed or pending checks.

Risk / follow-ups

This affects accepted signal graph promotion and stale waiter handling. #1784 is now integrated and the pending-reader regressions have been checked against its landed implementation. The separate ready-state staged-transition case #1767 remains outside this fix.

Provenance

  • An agent produced this diff (agent-authored)
  • Implementation task: 01a0d872-201b-7472-bbe9-adcca6ba2406; host: macOS development machine.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches core reactive graph promotion and async pending semantics; incorrect waiter transfer could cause infinite retries or missed updates, but change is narrowly scoped with extensive regression tests.

Overview
Fixes pending derived signals when a redeclared computation is accepted over an earlier one: readers must follow the live waiter, not a displaced or already-settled promise.

Signal graph (graph.ts): Wakeup objects track settled and resolve only once. Re-evaluation reuses an unsettled wakeup instead of allocating a new one. The pending “same result” fast path in sameViewResult now requires both waiters to be live and aligned with dependency order—not assuming two thrown thenables share one promise.

promoteDeclarationView: On acceptance, transfers the view’s wakeup to the canonical node, resolves the old waiter so stale async readers wake once, and forces retry when the accepted pending view’s waiter already settled or dependencies invalidated it before promotion (dirty flags, subscriber propagation, witness invalidation).

Tests: Graph, integration (view transitions), equivalent-pending waiter transfer, race watchdog against microtask loops, and thenable-per-read behavior.

Reviewed by Cursor Bugbot for commit c75ab59. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 5, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 0b77da8. Configure here.

Comment thread packages/octane/src/signals/graph.ts Resolved
@domgan-oai
domgan-oai marked this pull request as ready for review October 5, 2026 13:35
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 2 value(s) increased within budget

Compares 1de873c3a, the merge commit's first parent with bcc1dc931 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.192 3.133 ±0.0% −1.6% … +2.7% ⚪ within noise
octane-tsrx replace 7.775 6.992 −7.4% −19.9% … +0.0% ⚪ within noise
octane-tsrx add 2.983 2.758 ±0.0% −3.5% … +3.6% ⚪ within noise
octane-tsrx update 0.134 0.133 −1.0% −1.8% … +0.2% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.8% +0.0% … +2.1% ⚪ within noise
octane-tsrx swap 0.038 0.040 −0.4% −1.4% … +0.7% ⚪ within noise
octane-tsrx remove 0.021 0.021 +3.1% +1.1% … +4.4% ⚪ within noise
octane-tsrx runlots 28.950 28.775 +0.2% −2.7% … +1.8% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 +0.5% −0.7% … +2.1% ⚪ within noise
octane-tsrx clear 53.567 53.775 +0.7% −1.5% … +1.9% ⚪ within noise
octane-jsx run 3.783 3.900 +3.8% ±0.0% … +8.0% ⚪ within noise
octane-jsx replace 8.092 7.775 −1.9% −4.8% … +5.8% ⚪ within noise
octane-jsx add 3.650 3.642 −0.0% −2.6% … ±0.0% ⚪ within noise
octane-jsx update 0.275 0.278 +0.8% −0.4% … +1.7% ⚪ within noise
octane-jsx select 0.144 0.140 −1.6% −2.0% … −0.6% ⚪ within noise
octane-jsx swap 0.257 0.262 −1.1% −1.7% … −0.6% ⚪ within noise
octane-jsx remove 0.191 0.191 −0.3% −1.5% … +1.9% ⚪ within noise
octane-jsx runlots 33.075 32.583 +0.2% −3.5% … +1.4% ⚪ within noise
octane-jsx select_lots 1.670 1.734 +3.8% +2.5% … +6.0% ⚪ within noise
octane-jsx clear 55.325 55.417 −0.1% −2.3% … +3.1% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx bindings_js_gzip 239,233 239,220 −13 (−0.0%) 🟢
octane-tsrx bindings_js_brotli 203,802 203,803 +1 (+0.0%) 🔴
octane-tsrx bindings_app_gzip 121,383 121,370 −13 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 101,543 101,544 +1 (+0.0%) 🔴

56 other measured values are unchanged.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

@domgan-oai
domgan-oai marked this pull request as draft October 5, 2026 13:49
@domgan-oai
domgan-oai marked this pull request as ready for review October 5, 2026 20:57
@domgan-oai
domgan-oai merged commit 97f1b8e into octanejs:main Oct 6, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pending derived redeclaration can spin an async reader on a resolved waiter

1 participant