Skip to content

fix: retain suspended roots without a boundary - #833

Merged
trueadm merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-root-suspension-821
Aug 24, 2026
Merged

trueadm merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-root-suspension-821

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #821.

Retain and retry render-thrown thenables when no Suspense/@pending boundary owns them. Initial client mounts stay empty; updates retain the entire committed screen; initially suspended hydration preserves server DOM. Settlement retries current inputs, supersession/unmount cancels stale work, and actual rejections follow normal error routing.

Changes

  • Add root-local commit-wave journals for changed bindings and structure. Genuine replacements render once per attempt and keep outgoing DOM connected until commit, preserving state, input values/defaults, focus, handlers, refs, and effect lifetimes.
  • Carry root ownership through lightweight components and universal DOM boundaries; make compiled event writes journal-aware without changing native event semantics.
  • Integrate single-origin staged-state transitions: pending cues, repeated suspension, latest props, urgent cancellation, and rejection/unmount cleanup.
  • Add React/Octane dev/prod regressions, hydration/browser coverage, executable performance controls, parity-ledger evidence, documentation, and an octane patch changeset.

Unhandled effect errors now tear down their failed root. The review follow-up completes ref detachment before onUncaughtError, matching React's public callback observations. Two shadcn test files supply jsdom's missing matchMedia API exposed by that correction; mobile overrides and error assertions remain intact, with no binding workaround.

The CI follow-up (1df84a93c) adds the same scoped browser API fixture to Vaul. Its React differential oracle now opens the Octane drawer by its public label and asserts distinct, non-null framework outputs before comparing them; the previous first-button click could compare React with itself. The evidence hash is refreshed; production binding code and assertions are not weakened.

Validation

  • CI follow-up 1df84a93c: 3/3 Vaul tests passed after reproducing both missing-matchMedia failures and the self-comparing oracle. Parity metadata, formatting, and pnpm sync passed.
  • Follow-up 707afec86: 1,040 owning tests, 134 neighboring ref/error tests, and all 4 React/Octane dev/prod callback-oracle executions passed.
  • Initial 3f9b7c6: broad ordinary partition 20,126 passed, plus 2/2 isolated Rsbuild watcher tests; both commands exited successfully.
  • Initial 3f9b7c6: real-browser matrix 79 passed — 75 Octane and 4 Vite HMR cases, including all five native-focus retention variants.
  • Full workspace pnpm typecheck rerun for the follow-up. pnpm build and pnpm react-parity:validate passed on the initial implementation.
  • Full-repository Prettier check, pnpm sync, and clean diff review for the follow-up.
  • Fresh exact-source performance validation: 6 ordinary controls, 20 suspension/React controls, 5 executable bundle oracles, and one quiet timing pair. Both preceding v3 timing orders are preserved in the audit.
  • Original review thread resolved; Bugbot passed with no issues on 1df84a93c, with no unresolved threads.
  • Current-head required/relevant CI — all 26 jobs passed on 1df84a93c, including all ordinary/parity shards, browser, website, examples, package validation, lint, and typechecking.

Local tests used Node 26 with invocation-only NODE_OPTIONS=--no-experimental-webstorage, allowing jsdom to supply browser storage. The first broad run passed every assertion but hit macOS EMFILE; the clean final partition and isolated watcher run avoid that runner contention. The unfiltered pnpm test was not run locally: website and other heavy/browser integration lanes remain for CI.

Risk / follow-ups

Ordinary-render slowdown and bundle growth are material. This is not a zero-overhead change. Baseline is upstream fd6ce69c13daf7aa4eb41b4450382d6370b7993f; the fresh controls use source ab4765b11ebc7413ec49e8a367cc8f40367ad758e6c7d6c60d6835b4499238d9 (commit 707afec86).

Final cost Baseline → candidate
12 parent updates × 256 rows 2.00 → 3.36 ms (+68.0%); median 2.10 → 3.50 ms
256 independent descendant updates 0.32 → 0.36 ms (+12.5%; short/noisy)
Specialized-root executable gzip 13,069 → 16,071 bytes (+3,002; +23.0%)
Reusable-root executable gzip 37,811 → 43,458 bytes (+5,647; +14.9%)

The unchanged baseline drifted substantially between runs. The preceding v3 pairs (+116.1% and +94.6%, in opposite orders) remain fully recorded. No CPU gain is attributed to this cold error-path correction; these controls are not a precise general application estimate. Equal render/DOM counts do not establish equal CPU or allocation cost. See the performance audit and its JSON companion for commands, hashes, raw samples, bounded-work evidence, and limitations. No existing timing or byte budget was loosened.

Pending-cue/commit evidence covers single-origin staged-state root transitions, not simultaneous explicit-boundary/root holds, multi-origin staging, or external-store work-in-progress parity. This does not add time-slicing or a general concurrent renderer, nor guarantee that every eager native host mutation is unobservable.

Branch currency remains pending: upstream 69275956 has been merged and validated locally (1,094 runtime/ref tests, 3 Vaul tests, 22 Volar tests, full typecheck, build, formatting, parity metadata, sync, and fresh performance controls). The signing agent refuses the merge commit, so that merge and its refreshed performance audit are still staged and unpublished. The green CI above covers the published head, not a completed branch update.

Provenance

  • An agent produced this diff (agent-authored)

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


Note

High Risk
Touches core reconciler commit/rollback, hydration, events, and error teardown so suspended roots no longer unmount. Ordinary updates pay material journal overhead and ~15–23% gzip bundle growth.

Overview
Fixes #821: a thenable thrown during render with no enclosing Suspense/@pending boundary no longer tears down the root. Initial mounts stay empty; updates keep the last committed screen (identity, state, inputs, refs, effects, portals); hydration keeps server DOM until a successful retry can adopt it. Retries use latest inputs; supersession and unmount cancel stale work; real rejections still go through error boundaries / root callbacks. Effect-thrown thenables stay errors, and unhandled effect errors still unmount the failed root (refs detach before onUncaughtError).

The runtime journals root commit waves so structural replacements stay connected until commit, and compiled event writes go through journal-aware setEventHandler. Coverage includes differential/hydration/browser fixtures, a new root-suspension work runner, and a React-parity ledger case. This is not zero-cost: ordinary parent updates measure ~+68% on the recorded control, specialized-root gzip +~23%, reusable-root gzip +~15%. Single-origin staged transitions are in scope; multi-origin WIP and time-slicing are not.

Reviewed by Cursor Bugbot for commit 1df84a9. 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 Aug 23, 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 3f9b7c6. Configure here.

Comment thread packages/octane/src/runtime.ts Resolved
@domgan-oai
domgan-oai marked this pull request as ready for review August 23, 2026 21:50
@trueadm
trueadm merged commit 5f7a457 into octanejs:main Aug 24, 2026
31 checks passed
trueadm added a commit that referenced this pull request Oct 2, 2026
… fixtures in PR CI (#1583)

* fix(compiler): keep cached-array regions on signal-capable child holes

Since #1069, a renderable `{expr}` hole in a DOM template lowers to the
signal-capable `bindSignalChild` binding whenever the module can carry a
signal handle, which is any identifier hole. That branch returned before the
only-child path that wraps a compiler-owned calculated descriptor array in its
`compilerCacheArray` auto-memo region, so an unchanged array inside a
component-children body reached `childSlot` for the list and each item on
every parent render. The hook-memo provider-output guard
`inline_memo_snapshot_slots` rose from 0 to 256 per 128 updates.

Wrap the signal-capable binding in the same region. Only an unchanged plain
data array can hit; a signal handle or any other value fails
`compilerCacheArray` and rebinds every render, and the existing identity miss
rebuilds a previously cached array after the hole held something else.

The new value-position case switches one calculated child between cached rows
and a signal handle. It fails in the production compile when the region's
identity miss is dropped, and passes on the uncached path too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE

* test(bench): report hook-memo scenarios net of the root update driver

Eight hook-memo ratio guards breached on main (eligible hit functions 704,
eligible hit arrays 3,872, and so on) while the inline memo tier's own counts
were unchanged. Per-site attribution put every excess event in the runtime's
same-component `root.render()` path: the per-update request/retry closures
and the root render transaction's undo log, OffscreenCapture arrays and
committed-transaction queue, 2 functions and 10 arrays per render in both
compiler variants. Bisecting `run.mjs` output found 5f7a457 (#833, root
render transactions) to be the first breaching commit; it did not touch this
benchmark, and its documented root-transaction cost is unrelated to hooks.

Add a hook-free Driver control that runs the identical phase sequence, report
every scenario net of the driver's same-phase counts (failing the run if a
scenario falls below it), and keep raw counters in the JSON metadata. Two new
guards pin the driver's per-update cost at its current 2 functions and
10 arrays so the root update path cannot grow silently.

The corrected runner reports identical net counts on both sides of #833, and
against 814a3c1 (before closure-free memo lowering) it still breaches the
same seven memo guards the original measurement recorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE

* ci: check the Lynx bench fixture contracts on every pull request

The weekly Bench workflow runs the Lynx table-stage and list fixture
contracts before its ratio guards. Those tests compile copies of
packages/lynx/src, and Lynx changes broke them twice (09-21: an unresolved
`octane/internal/context` import; 09-28: a removed `universalBlock` export,
fixed on main by #1391). PR CI never ran them, so each break surfaced only
in the next weekly run and kept every ratio guard from executing.

Add both suites to `ci:workflow:test`, which the lint job runs on every
ready pull request, and assert the two lists stay aligned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE

* fix(compiler): keep raw-HTML hosts off the cached signal child region

A host that may receive dangerouslySetInnerHTML, directly or through a
spread, must reach its child binding on every render: that call is where
children and raw HTML are kept mutually exclusive. The ordinary only-child
path already checks this before choosing the cached-array region, but the
region restored around bindSignalChild did not, so an unchanged cached array
let a spread add raw HTML beside still-mounted rows without the error.

Skip the region for such hosts, as the ordinary path does. The new spread
case fails in the production compile without the guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE

---------

Co-authored-by: Claude <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…d can produce (#1661)

#1279 made the plain-object memo compare check own-property membership for
every key, so an inherited Object.prototype value cannot stand in for a
removed prop. On a plain or null-prototype object a missing own prop reads as
undefined or an Object.prototype member, which is a function or an object, so
a primitive that compares equal is already own. The lookup now runs only for
undefined, function and object values.

memo-wall's wall B bails 999 rows of four primitive props and a callback on
every one_change_B; it made five lookups per row and now makes one. Paired
A/B with the #833/#1069 fixes: one_change_B 0.269 -> 0.252 ms.

memo-props gains a case for an own __proto__ prop holding Object.prototype
(the object branch; it fails without it), and memo-wall gains a deterministic
guard counting own-prop lookups per bailed row (5 on main, 1 now).

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…cord (#1656)

* perf(octane): restore keyed survivor indices from the list's shape record

#833 made root renders undoable and journaled every keyed survivor's previous
itemIndex in updateSurvivor: four journal slots per row on each reorder,
removal, or insertion that shifts positions. A same-runner paired A/B put a
1,000-row rotate at 0.050 ms before #833 and 0.071 ms on main.

An index moves only when the list's membership or order does, which records
the list's shape (journalForSlot) anyway. reconcileKeyed now takes that
record before the first survivor index write, and restoreForSlot restores
each row's itemIndex from its chain position; a row whose index already
differed is kept exactly. The hydration adoption branch, which restores a DOM
range instead of a chain, still journals indices per row. Transition journals,
which never restored itemIndex, now restore it too.

The shape record also builds the key order with one spread and an early-exit
comparison instead of an iterator loop that copied the order element by
element.

The root-transactions suite gains reorders.mjs, which counts root-journal
slots per row for rotate/reverse/remove-first/insert-first (4 on main, 0
now). A held-root test pins that index-reading rows render their positions
after a held reorder retries; it fails when the index restore is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): trim the keyed index journal to +51 raw / +10 gzip bytes

The bench report on this PR measured +250 raw / +90 gzip bytes in every
bundle with a keyed list. journalForSlot now returns false, so the call
sites clear their pending flag without a helper. Rollback restores each
row's index from its chain position without a side map, since every
reconcile leaves a row's index equal to its position and the record is
taken before the first survivor index write. The hydration-adoption branch
does not restore a chain at all (its rows are fresh), so it no longer
journals indices per row either.

js-framework octane-tsrx bundle against main: +51 raw / +10 gzip (was
+251 / +51). The held-root index test still fails when the restore is
removed; the reorder guard still reads 0 slots per row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): keep row indices across a hydrating keyed rollback

The hydration-adoption branch of journalForSlot restores a DOM range, not a
chain, so the trim that dropped its per-row index entries left an existing
row's itemIndex on the aborted position after a hydrating render reordered
the list and rolled back. Journal each existing row's index there again,
before reconcileKeyed moves any of them. Bundle cost against main is now
+130 raw / +31 gzip for js-framework octane-tsrx.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…ng its render (#1664)

* perf(octane): record event signal authority on the host instead of weak maps

#1069 made every module that can receive a signal handle record each native
handler's signal authority: the element's owner in one weak map and an
"escaped" mark for the scope in another. Keyed rows paid two weak-map
insertions per mounted row even with no signals in use. A same-runner paired
A/B put prepend100/append100/insertmid100 at 0.48 -> 0.76 ms across #1069.

The element's authority now lives in a $$signalOwner property beside its
handler slots, journaled and rolled back like before, and the escape mark is a
signalTokenEscaped field on Scope/Block with the same retirement truth table.
Mounting no longer touches a weak map.

bindSignalText also writes a scalar over the Text it already owns directly,
skipping bindDirectSignal's policy dispatch; setText still journals the text
and the binding bag. That path runs for every compiled text-hole update in
such a module (memo-wall context refresh: 0.669 -> 0.622 ms paired).

The signal-dom-bindings suite gains a deterministic guard counting weak-map
insertions per mounted and inserted handler row (2 on main, 0 now), with
dispatch and survivor-identity controls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): restore keyed survivor indices from the list's shape record

#833 made root renders undoable and journaled every keyed survivor's previous
itemIndex in updateSurvivor: four journal slots per row on each reorder,
removal, or insertion that shifts positions. A same-runner paired A/B put a
1,000-row rotate at 0.050 ms before #833 and 0.071 ms on main.

An index moves only when the list's membership or order does, which records
the list's shape (journalForSlot) anyway. reconcileKeyed now takes that
record before the first survivor index write, and restoreForSlot restores
each row's itemIndex from its chain position; a row whose index already
differed is kept exactly. The hydration adoption branch, which restores a DOM
range instead of a chain, still journals indices per row. Transition journals,
which never restored itemIndex, now restore it too.

The shape record also builds the key order with one spread and an early-exit
comparison instead of an iterator loop that copied the order element by
element.

The root-transactions suite gains reorders.mjs, which counts root-journal
slots per row for rotate/reverse/remove-first/insert-first (4 on main, 0
now). A held-root test pins that index-reading rows render their positions
after a held reorder retries; it fails when the index restore is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(bench): observe stable event authority on the host property

The stable-event-authority work observer counted authority writes through
WeakMap.prototype.set. Authority now lives in each host's $$signalOwner
property, so the observer counts writes through an Element.prototype
accessor instead. The expected counts are unchanged (400 mount, 0 retained,
0 changed capture), and dropping the runtime's unchanged-authority skip
still fails the retained-write assertion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): trim the keyed index journal to +51 raw / +10 gzip bytes

The bench report on this PR measured +250 raw / +90 gzip bytes in every
bundle with a keyed list. journalForSlot now returns false, so the call
sites clear their pending flag without a helper. Rollback restores each
row's index from its chain position without a side map, since every
reconcile leaves a row's index equal to its position and the record is
taken before the first survivor index write. The hydration-adoption branch
does not restore a chain at all (its rows are fresh), so it no longer
journals indices per row either.

js-framework octane-tsrx bundle against main: +51 raw / +10 gzip (was
+251 / +51). The held-root index test still fails when the restore is
removed; the reorder guard still reads 0 slots per row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): keep row indices across a hydrating keyed rollback

The hydration-adoption branch of journalForSlot restores a DOM range, not a
chain, so the trim that dropped its per-row index entries left an existing
row's itemIndex on the aborted position after a hydrating render reordered
the list and rolled back. Journal each existing row's index there again,
before reconcileKeyed moves any of them. Bundle cost against main is now
+130 raw / +31 gzip for js-framework octane-tsrx.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): update a same-component de-opt list item without entering its render

A value-position list rebuilt by createElement (memo-wall wall B, every
@octanejs binding) hands back a fresh descriptor per row. Each surviving row
entered its item render (renderBlock, deoptItemBody, a nested childSlot) only
to reach the memo bail of the component already mounted there, and the root
journal recorded the item's inputs and render for every row.

updateSurvivor now hands a plain de-opt item to updateDeoptComponent, which
takes that nested childSlot's same-component branch directly, in the item's
scope and with the priority its render would inherit: the memo bail, the
identical-props bail, or a journaled props update and render of the existing
component Block. A bail leaves the item's committed descriptor in place.
Hydration, signal owners, native reads, non-root captures, unsettled items and
every other child regime keep the ordinary item render. The function reaches
updateSurvivor through ForSlot.itemUpdate, stamped in renderPreparedChildList,
so compiled @for bundles never retain the descriptor renderer.

Per bailed row (new memo-wall survivor-work guard, jitless precise calls):
48 calls and 8 root-journal slots before, 26 and 0 now. One __oneChangeB on
the memo-wall production build: 46,138 calls before, 24,138 now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): point childSlot's same-component branch at its de-opt item twin

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): drop de-opt item fast-path checks its component Block already implies

An item whose nested slot holds a component Block never has recorded
$$ctxReads (it is neither memo nor armed) and never also holds a portal.
Its end marker and a former body-function flag do not change the
same-component branch it mirrors. A non-object item fails the kind check
without the separate null and typeof tests. -100 raw / -17 gzip in bundles
that include the descriptor renderer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): drop the one_change_B waiver and tighten its guard to 1.1

#1646 waived memo-wall one_change_B (octane-tsrx/react, maxRatio 1.4) until
the per-row survivor work was fixed. With same-component de-opt survivors
taking the memo bail directly, paired ~20 ms samples measured 0.80x, 0.80x
and 0.82x across two same-runner runs (the previous code: 1.30-1.41x; #639:
0.97x). 1.1 keeps about 35% headroom while catching a return of the per-row
item render.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): carry the de-opt survivor update in ForSlot.plainDeopt

The plain de-opt flag now holds the list's survivor update itself
(updateDeoptComponent, or null), so ForSlot needs no second field and the
compiled @for path that shares updateSurvivor pays only one optional call.
updateDeoptComponent writes the survivor's index. The js-framework rows app
(compiled lists only) now grows +20 raw / +11 gzip over main, within the
committed +32 budget, instead of +74 / +29.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Retain and retry a suspended root when no Suspense boundary is present

2 participants