Skip to content

fix: hold root.render transitions that suspend into a held boundary - #2283

Merged
trueadm merged 3 commits into
mainfrom
fix/held-root-render-transition
Oct 29, 2026
Merged

trueadm merged 3 commits into
mainfrom
fix/held-root-render-transition

Conversation

@trueadm

@trueadm trueadm commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1341. startTransition(() => root.render(App, next)) that suspends into a @try showing committed content now holds the whole screen, the way a hook-driven transition already does. A useSyncExternalStore notification during the hold now updates the selection that is still on screen.

Why

The issue's follow-up comment found two causes:

  1. useSyncExternalStore wrote inst.getSnapshot = getSnapshot during render without journaling it. When the boundary held, the store cell kept the pending selector (b), so checkStoreChanged compared the committed value against b's value and dropped the notification.
  2. A root.render transition folds no hook work, so dropTransitionRender returned false. The boundary held on its own and the root's new props committed early. The re-render that the notification forced then read k: 'b' and showed @pending.

Fixing only the first cause swaps the stale value for a loading flash, so both changes ship together.

Changes

  • useSyncExternalStore journals the selector write when its identity changes. A dropped render restores the selector the held screen shows.
  • dropTransitionRender also drops the transaction when the drained origin applied its root's request at transition priority. Each holding boundary records that request by owner generation (TransitionHold.request).
  • A boundary releasing its hold retries the request at transition priority (retryRootRequest). Inside a render or flush, the retry waits for the transition task, as retryTransitionBatch does. This happens when its data settles, when its timeout fallback shows (unsuspendTransitionHolder), or when a new update wakes it.
  • A later root.render or the request's own commit bumps the generation. A stale hold then retries nothing, and the boundary resumes on its own path.
  • holdsUnrenderedTransition keeps the hold through renders that did not render the root request, such as the urgent store re-render.
  • SUSPENSE_DIVERGENCE.md §4 and the runtime comments now say root.render transitions are covered. Transitions with no queued work at all remain per boundary.

Validation

  • pnpm format:check: not run repo-wide; pnpm format:files:check passes on every changed file.

  • pnpm typecheck: not run repo-wide; pnpm typecheck:files passes on engine.ts, transitions.ts and the fixture. The test file shows two existing TS4111 process.env.NODE_ENV errors, on lines already in main.

  • pnpm test: not run locally; CI runs it.

  • Targeted tests, octane project, all passing: 49 files and 1,419 tests across transition*, suspense*, root-, behavior-root, sync/external store, and conformance entangled-commit, parallel-transitions, fuzz-suspense, suspense-, transitions-extra, view-transition, sync-store-tearing. Also the differential transition-swap* and suspense-timing tests. external-store-behavior.test.ts also passes under octane-prod.

  • New regression tests in external-store-behavior.test.ts, under "a root.render transition that suspends into a held boundary":

    • keeps the store selection of the screen it holds live (the issue's repro, plus a label outside the boundary) fails on main.
    • keeps holding when the retried request suspends again fails on main.
    • lets a later urgent root.render replace the held request passes on both. It guards against a retry reviving the replaced request.
    • Disabling either half of the fix makes the first test fail again.
  • perf-review: node scripts/perf-review-scan.mjs reports no candidates. The one hot-path change is in the useSyncExternalStore update path: a journalRootProperty call when the selector identity changes. Same-session A/B with node benchmarks/external-store-fanout/run.mjs octane-tsrx 8, which uses 512 inline-selector subscribers, so the entry fires on every subscriber render:

    op base, two runs (ms) branch, two runs (ms)
    broad_write 16.86 / 17.00 16.74 / 16.60
    narrow_write 19.04 / 18.92 18.86 / 18.98
    rapid_writes 15.58 / 15.60 15.84 / 15.92
    mount 48.48 / 54.02 51.86 / 53.16

    The update ops are flat. Mount runs unchanged code, and its run-to-run spread is wider than the base-to-branch gap. Everything else runs only while a transition hold exists. TransitionHold keeps a single allocation site with one key set.

  • concise-code: src +115 −24 (runtime +115 −24), comments included. One new runtime export, retryRootRequest, called from transitions.ts. suspendingTransitionHold is now exported, replacing a one-line holdRootRequest wrapper. No new files apart from the changeset.

    • Rejected: modelling the root request as a synthetic TransitionActionBatch. It would need fold and pending-hook semantics a root request does not have, and re-arming owner.request would let an urgent root render apply it.
    • Rejected: making the root owner the holder, as the no-boundary path does. root.render (keepTransition) and commit (the request's generation bump) already treat an owner hold as held hook work, so reusing it would change their behavior for hook transitions.
    • Bytes, node benchmarks/bundle-size/run-minimal.mjs base vs branch:
      • +744–747 raw / +176–230 gzip in transition and Suspense scenarios (suspense-transition, split-shell*, descriptor-children, binding-{radix,base-ui,apollo-client}).
      • +419 raw / +77–105 gzip in signal-*, hydrate-frame and deferred-hydration.
      • +35 raw / +7 gzip in binding-hooks, which is the selector journal.
      • No other rows moved. The CI report rows are authoritative.
  • CI benchmark report on 2f5b7fc0:

    • All 64 js-framework work counters are unchanged.
    • Byte rows match the local numbers above, for example shell_js +723 raw / +201 gzip and bindings_fw +754 raw / +225 gzip.
    • The one wall-time verdict is octane-jsx add at +6.4% (95% CI +3.0% … +12.2%). That operation reaches no useSyncExternalStore, transition or hold code; octane-tsrx add is ±0.0% and every other operation is within noise. I read it as code layout or runner noise, not a cost of this change.

Risk / follow-ups

  • When several boundaries hold one request, each forms its own reveal group, so each settle retries the request. A retry that reaches a boundary still waiting holds again, so this costs extra transition renders but shows no extra states. Grouping them would save those renders, but a shared group can include plain no-batch holds whose resume a retry would skip, so I left it out.
  • useTransition's start(() => root.render(...)) still raises no isPending for the held request; a root request has no batch for a hook to count. That was true before this change.
  • An urgent update to the root component itself can still apply a pending root.render request at urgent priority. That is how root requests already queue (owner.request) and is unchanged here.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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


Note

Medium Risk
Changes Suspense transition commit, root render queuing, and the useSyncExternalStore update path; behavior is narrow but sits on critical render/commit infrastructure.

Overview
startTransition(() => root.render(...)) that suspends while a @try boundary still shows committed content now drops the whole root transaction and keeps the previous screen—including props outside the boundary—until the held request retries, matching hook-driven transition holds (#1341).

The runtime records the suspended root.render generation on each TransitionHold, retries it via retryRootRequest when the boundary releases, and treats a newer root.render or commit as superseding the hold. dropTransitionRender, holdsUnrenderedTransition, and transition-task scheduling were extended for root requests alongside existing batch holds.

useSyncExternalStore now journals getSnapshot identity changes during update so a dropped transition render restores the selector the committed UI still uses; store notifications during the hold update the visible selection in place instead of reading the pending tree’s selector or flashing @pending.

Docs in SUSPENSE_DIVERGENCE.md and runtime comments note that root.render transitions share the whole-screen hold behavior. New HeldSelectionBoundary regression tests cover live store updates while held, double suspend on retry, coexisting hook transitions, and urgent superseding renders.

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

A root.render request rendered at transition priority now drops its
whole root transaction when it suspends into a boundary holding committed
content, as hook-driven transitions already do. Each holding boundary
keeps the request (by owner generation) and retries it at transition
priority when its data settles, its timeout fallback shows, or a new
update wakes it. A later request or its commit replaces the held one.

useSyncExternalStore journals its render-time getSnapshot write, so a
dropped render restores the selector the held screen still shows and a
store notification updates that screen instead of consulting the
pending selector.

Fixes #1341.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 29, 2026
@trueadm
trueadm marked this pull request as ready for review October 29, 2026 10:42
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 2023fba Commit Preview URL

Branch Preview URL
Oct 29 2026, 11:10 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 2023fba Commit Preview URL

Branch Preview URL
Oct 29 2026, 11:10 AM

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 54 value(s) increased
  • 🔴 bundle-reachability: 45 value(s) increased

Compares 3f3bf1ab7, the merge commit's first parent with 14638f533 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. 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 2.475 2.550 +3.8% −3.7% … +4.0% ⚪ within noise
octane-tsrx replace 5.400 5.275 ±0.0% −3.9% … +4.9% ⚪ within noise
octane-tsrx add 2.200 2.200 ±0.0% −0.0% … +0.0% ⚪ within noise
octane-tsrx update 0.073 0.072 +0.4% −0.4% … +2.5% ⚪ within noise
octane-tsrx select 0.005 0.005 −0.3% −0.5% … +0.5% ⚪ within noise
octane-tsrx swap 0.016 0.016 +1.1% +0.0% … +2.2% ⚪ within noise
octane-tsrx remove 0.014 0.014 −0.9% −2.7% … +1.8% ⚪ within noise
octane-tsrx runlots 20.875 22.850 −1.9% −6.2% … +2.3% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 ±0.0% −0.6% … +0.6% ⚪ within noise
octane-tsrx clear 44.225 46.083 +1.5% −0.6% … +3.2% ⚪ within noise
octane-jsx run 3.500 3.400 ±0.0% −3.0% … +0.0% ⚪ within noise
octane-jsx replace 5.450 5.542 +0.7% −4.5% … +4.9% ⚪ within noise
octane-jsx add 2.850 2.833 −0.0% −3.4% … +0.0% ⚪ within noise
octane-jsx update 0.157 0.156 −0.6% −1.3% … +0.0% ⚪ within noise
octane-jsx select 0.080 0.076 ±0.0% −0.3% … +0.5% ⚪ within noise
octane-jsx swap 0.121 0.121 ±0.0% −0.0% … +0.6% ⚪ within noise
octane-jsx remove 0.102 0.105 ±0.0% −0.5% … +1.2% ⚪ within noise
octane-jsx runlots 25.392 26.283 +0.4% −4.4% … +4.7% ⚪ within noise
octane-jsx select_lots 0.812 0.801 −2.1% −2.9% … −0.5% ⚪ within noise
octane-jsx clear 46.008 46.383 −0.6% −1.9% … +4.0% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx bindings_js_raw 680,937 681,691 +754 (+0.1%) 🔴
octane-tsrx bindings_js_gzip 225,767 225,992 +225 (+0.1%) 🔴
octane-tsrx bindings_js_brotli 192,775 192,757 −18 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 98,707 98,687 −20 (−0.0%) 🟢
octane-tsrx bindings_fw_raw 323,029 323,783 +754 (+0.2%) 🔴
octane-tsrx bindings_fw_gzip 107,102 107,327 +225 (+0.2%) 🔴
octane-tsrx bindings_fw_brotli 94,068 94,070 +2 (+0.0%) 🔴
octane-tsrx shell_js_raw 288,815 289,538 +723 (+0.3%) 🔴
octane-tsrx shell_js_gzip 94,353 94,554 +201 (+0.2%) 🔴
octane-tsrx shell_js_brotli 82,162 82,332 +170 (+0.2%) 🔴
octane-tsrx shell_app_gzip 1,148 1,154 +6 (+0.5%) 🔴
octane-tsrx shell_app_brotli 1,006 1,013 +7 (+0.7%) 🔴
octane-tsrx shell_fw_raw 286,916 287,639 +723 (+0.3%) 🔴
octane-tsrx shell_fw_gzip 93,205 93,400 +195 (+0.2%) 🔴
octane-tsrx shell_fw_brotli 81,156 81,319 +163 (+0.2%) 🔴
octane-tsrx shell_client_js_raw 233,706 234,429 +723 (+0.3%) 🔴
octane-tsrx shell_client_js_gzip 76,238 76,424 +186 (+0.2%) 🔴
octane-tsrx shell_client_js_brotli 67,102 67,304 +202 (+0.3%) 🔴
octane-tsrx shell_client_app_gzip 1,157 1,156 −1 (−0.1%) 🟢
octane-tsrx shell_client_app_brotli 1,010 1,014 +4 (+0.4%) 🔴
octane-tsrx shell_client_fw_raw 231,799 232,522 +723 (+0.3%) 🔴
octane-tsrx shell_client_fw_gzip 75,081 75,268 +187 (+0.2%) 🔴
octane-tsrx shell_client_fw_brotli 66,092 66,290 +198 (+0.3%) 🔴
octane-tsrx wayfinder_js_raw 357,900 358,677 +777 (+0.2%) 🔴
octane-tsrx wayfinder_js_gzip 117,981 118,210 +229 (+0.2%) 🔴
octane-tsrx wayfinder_js_brotli 102,222 102,468 +246 (+0.2%) 🔴
octane-tsrx threadline_oxc_js_raw 136,644 136,679 +35 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_gzip 45,808 45,815 +7 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_brotli 40,393 40,409 +16 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_raw 175,593 175,648 +55 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_gzip 59,424 59,441 +17 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_brotli 52,410 52,411 +1 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_raw 547,035 547,813 +778 (+0.1%) 🔴
octane-tsrx pagecraft_oxc_js_gzip 172,601 172,801 +200 (+0.1%) 🔴
octane-tsrx pagecraft_oxc_js_brotli 146,770 146,918 +148 (+0.1%) 🔴
octane-tsrx pagecraft_esbuild_js_raw 582,486 583,269 +783 (+0.1%) 🔴
octane-tsrx pagecraft_esbuild_js_gzip 189,012 189,235 +223 (+0.1%) 🔴
octane-tsrx pagecraft_esbuild_js_brotli 160,810 160,951 +141 (+0.1%) 🔴
octane-tsrx full_fw_raw 535,580 536,357 +777 (+0.1%) 🔴
octane-tsrx full_fw_gzip 168,183 168,422 +239 (+0.1%) 🔴
octane-tsrx full_fw_brotli 143,069 143,335 +266 (+0.2%) 🔴
octane-jsx shell_js_raw 338,102 338,825 +723 (+0.2%) 🔴
octane-jsx shell_js_gzip 110,388 110,589 +201 (+0.2%) 🔴
octane-jsx shell_js_brotli 95,946 95,994 +48 (+0.1%) 🔴
octane-jsx shell_app_gzip 771 772 +1 (+0.1%) 🔴
octane-jsx shell_app_brotli 668 663 −5 (−0.7%) 🟢
octane-jsx shell_fw_raw 336,999 337,722 +723 (+0.2%) 🔴
octane-jsx shell_fw_gzip 109,617 109,817 +200 (+0.2%) 🔴
octane-jsx shell_fw_brotli 95,278 95,331 +53 (+0.1%) 🔴
octane-jsx shell_client_js_raw 282,749 283,472 +723 (+0.3%) 🔴
octane-jsx shell_client_js_gzip 91,793 92,017 +224 (+0.2%) 🔴
octane-jsx shell_client_js_brotli 80,510 80,696 +186 (+0.2%) 🔴
octane-jsx shell_client_app_gzip 780 772 −8 (−1.0%) 🟢
octane-jsx shell_client_app_brotli 678 673 −5 (−0.7%) 🟢
octane-jsx shell_client_fw_raw 281,638 282,361 +723 (+0.3%) 🔴
octane-jsx shell_client_fw_gzip 91,013 91,245 +232 (+0.3%) 🔴
octane-jsx shell_client_fw_brotli 79,832 80,023 +191 (+0.2%) 🔴
octane-jsx full_fw_raw 535,580 536,357 +777 (+0.1%) 🔴
octane-jsx full_fw_gzip 168,183 168,422 +239 (+0.1%) 🔴
octane-jsx full_fw_brotli 143,069 143,335 +266 (+0.2%) 🔴

51 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
signal-counter raw 107,459 107,878 +419 (+0.4%) 🔴
signal-counter gzip 35,566 35,671 +105 (+0.3%) 🔴
signal-counter brotli 32,104 32,232 +128 (+0.4%) 🔴
signal-instance-derived raw 123,530 123,949 +419 (+0.3%) 🔴
signal-instance-derived gzip 40,111 40,202 +91 (+0.2%) 🔴
signal-instance-derived brotli 36,273 36,348 +75 (+0.2%) 🔴
deferred-hydration raw 185,617 186,036 +419 (+0.2%) 🔴
deferred-hydration gzip 60,752 60,846 +94 (+0.2%) 🔴
deferred-hydration brotli 53,157 53,225 +68 (+0.1%) 🔴
hydrate-frame raw 343,119 343,538 +419 (+0.1%) 🔴
hydrate-frame gzip 110,588 110,665 +77 (+0.1%) 🔴
hydrate-frame brotli 96,255 96,314 +59 (+0.1%) 🔴
suspense-transition raw 150,022 150,744 +722 (+0.5%) 🔴
suspense-transition gzip 49,060 49,245 +185 (+0.4%) 🔴
suspense-transition brotli 43,424 43,587 +163 (+0.4%) 🔴
descriptor-children raw 144,019 144,740 +721 (+0.5%) 🔴
descriptor-children gzip 47,126 47,327 +201 (+0.4%) 🔴
descriptor-children brotli 42,033 42,233 +200 (+0.5%) 🔴
binding-hooks raw 54,603 54,638 +35 (+0.1%) 🔴
binding-hooks gzip 19,220 19,227 +7 (+0.0%) 🔴
split-shell raw 396,334 397,057 +723 (+0.2%) 🔴
split-shell gzip 129,474 129,639 +165 (+0.1%) 🔴
split-shell brotli 112,899 113,062 +163 (+0.1%) 🔴
split-shell-runtime raw 323,738 324,461 +723 (+0.2%) 🔴
split-shell-runtime gzip 104,505 104,671 +166 (+0.2%) 🔴
split-shell-runtime brotli 90,334 90,496 +162 (+0.2%) 🔴
binding-base-ui-vite raw 156,780 157,501 +721 (+0.5%) 🔴
binding-base-ui-vite gzip 51,542 51,693 +151 (+0.3%) 🔴
binding-base-ui-vite brotli 45,806 46,003 +197 (+0.4%) 🔴
binding-base-ui-esbuild raw 200,325 201,049 +724 (+0.4%) 🔴
binding-base-ui-esbuild gzip 67,614 67,801 +187 (+0.3%) 🔴
binding-base-ui-esbuild brotli 59,847 60,099 +252 (+0.4%) 🔴
binding-radix-vite raw 154,127 154,849 +722 (+0.5%) 🔴
binding-radix-vite gzip 50,551 50,750 +199 (+0.4%) 🔴
binding-radix-vite brotli 45,026 45,124 +98 (+0.2%) 🔴
binding-radix-esbuild raw 197,837 198,561 +724 (+0.4%) 🔴
binding-radix-esbuild gzip 66,719 66,906 +187 (+0.3%) 🔴
binding-radix-esbuild brotli 59,060 59,180 +120 (+0.2%) 🔴
binding-mantine-hooks-esbuild brotli 25,628 25,689 +61 (+0.2%) 🔴
binding-apollo-client-vite raw 302,759 303,482 +723 (+0.2%) 🔴
binding-apollo-client-vite gzip 94,749 94,926 +177 (+0.2%) 🔴
binding-apollo-client-vite brotli 84,079 84,265 +186 (+0.2%) 🔴
binding-apollo-client-esbuild raw 354,356 355,080 +724 (+0.2%) 🔴
binding-apollo-client-esbuild gzip 115,239 115,442 +203 (+0.2%) 🔴
binding-apollo-client-esbuild brotli 101,688 101,854 +166 (+0.2%) 🔴
binding-usehooks-ts-esbuild brotli 25,879 25,860 −19 (−0.1%) 🟢

95 other measured values are unchanged.

@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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Request-only holds skip origin replay
    • Initialized first to request && batches.length === 0 so a request-only dropTransitionRender passes all=true to renderDroppedTransaction, replaying all drain origins instead of only urgent ones.

Create PR

Or push these changes by commenting:

@cursor push 9f95d3e476
Preview (9f95d3e476)
diff --git a/packages/octane/src/runtime/transitions.ts b/packages/octane/src/runtime/transitions.ts
--- a/packages/octane/src/runtime/transitions.ts
+++ b/packages/octane/src/runtime/transitions.ts
@@ -733,7 +733,7 @@
 		__profileCount(ProfileCounter.ROLLBACK_TRANSITION);
 	if (TRANSITION_HARVEST !== null)
 		for (let i = 0; i < TRANSITION_HARVEST.length; i++) TRANSITION_HARVEST[i].taken = false;
-	let first = false;
+	let first = request && batches.length === 0;
 	for (const batch of batches) {
 		if (!batch.held) first = batch.held = true;
 	}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 13d07f4. Configure here.

The root's render skips a memoized counter, which renders its own
transition update in the drain that drops the held root.render request.
A drain renders each wave shallow-first, so that update renders after
the drop, in a fresh transaction, and commits; the test fails if the
drop left later origins in the dropped transaction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 70e0de0 into main Oct 29, 2026
33 checks passed
@trueadm
trueadm deleted the fix/held-root-render-transition branch October 29, 2026 11:37
@github-actions github-actions Bot mentioned this pull request Oct 29, 2026
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.

Suspended root-prop transitions make useSyncExternalStore miss updates to the visible selection

1 participant