Repository navigation
fix(suspense): keep a pending boundary's query$ loads across parent renders - #1620
Merged
Merged
Conversation
…enders A parent render that gave a pending Suspense boundary new children (every render of a JSX <Suspense>, even with equal props) or new inputs (a compiled @Try) restarted the uncommitted attempt and retired its signal owners. Each render started the load again, and a parent that re-rendered faster than the load settled kept the fallback up forever. On a client root, restartUncommittedTry now hands the abandoned primary's owners to the boundary's retry cache, and the replacement claims them by path. The old scopes are marked ownerless rather than relying on the retained-owner window, because a root render defers their teardown to its commit. During hydration the supersede path prunes the cache instead of clearing it. A redeclared query$ re-selects from the new inputs and shares an equal in-flight request. Owners holding an authored signal$ or an asynchronous derived$ still restart, since those cells cannot follow new inputs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 23:41
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
6 other measured values are unchanged. Public-import reachability bundles (bytes)
69 other measured values are unchanged. |
The detach parameter on retainSignalRetryScope added 22 bytes to every bundle that can reach root suspension, which put root-chained-jsx over its budget. Only a restarted Suspense primary hands owners to a replacement, so detach its scopes in a separate walk on that path. The facade's follows-inputs predicate is also exported as a live binding rather than through a wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pending boundary that restarts with a changed selection kept the abandoned attempt's request in flight until the boundary revealed, because the kept cell staged the new selection as a private view. That cell was never presented by a committed render. Supersession now marks the kept cells provisional: until a render declaring them is accepted, a discarded render's definition replaces the abandoned one, so the obsolete request is aborted as soon as the restarted attempt suspends. This restores the pending native stream contract in signals-pending-stream.test.ts. 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: Nested query owners leak on restart
- Passed includeHiddenTry=false to forEachSubtreeChild in retainSignalRetryScope and detachSignalRetryScope so nested Suspense boundaries' hidden primaries are not walked, preventing inner owners from leaking onto the outer boundary's cache.
Or push these changes by commenting:
@cursor push ced00597bb
Preview (ced00597bb)
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
@@ -698,7 +698,7 @@
}
}
if (subtree)
- forEachSubtreeChild(scope, (child) => retainSignalRetryScope(child, root, holder, true));
+ forEachSubtreeChild(scope, (child) => retainSignalRetryScope(child, root, holder, true), false);
else if (scope.children !== null)
for (const child of scope.children) retainSignalRetryScope(child.scope, root, holder);
}
@@ -709,7 +709,7 @@
function detachSignalRetryScope(scope: Scope, cache: SignalRetryOwners): void {
const owner = SCOPE_SIGNAL_OWNERS.get(scope);
if (owner && cache.owners.has(owner)) SCOPE_SIGNAL_OWNERS.set(scope, false);
- forEachSubtreeChild(scope, (child) => detachSignalRetryScope(child, cache));
+ forEachSubtreeChild(scope, (child) => detachSignalRetryScope(child, cache), false);
}
function clearSignalRetryOwners(holder: { retrySignalOwners?: SignalRetryOwners }): void {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 4352a7a. Configure here.
…-over The restart hand-over walked into nested Suspense primaries and parked their owners in the outer boundary's retry cache. A nested primary claims only from its own cache, so those owners were never reclaimed: the replacement started a new load while the old nested request stayed in flight until the outer boundary revealed. The hand-over now has its own walk, which stops at a non-propagating nested boundary, as signalRetryBoundary does. Those owners stay mapped and retire with the abandoned tree. The walk also replaces the separate detach pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
….com/octanejs/octane into fix/jsx-boundary-parent-render-query
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
<Suspense>boundary no longer restarts itsquery$loads whenever its parent renders. Before this, a JSX<Suspense>lost them on every parent render, even with equal props. A compiled@trylost them on any new input. When the parent re-rendered faster than a load settled, the fallback stayed up forever.query$re-selects from the new inputs, as fix(octane): re-select component-local query$ when captured props change #1550 made it do, and shares the load already in flight when its selection is unchanged. A changed selection starts its own load and aborts the old one immediately. Hooks still start fresh, as before.Why
The 2026-10-02 review of PRs merged since 85cb387 rated this P1 (finding D1). #1607 covered only a boundary retrying itself. A parent render still superseded the attempt through two paths:
tryBlocksees new children (a JSX boundary builds new descriptors every render) and callsattemptHiddenReveal(…, 'parent').restartUncommittedTrythen unmounts the hidden primary, which retires every signal owner in it. The replacement mints new owners and starts another load.supersedesInputsbranch intryBlockcleared the boundary's retained retry owners.Repro (client root;
Appre-renders, renderingSuspense > Mid > Field, whereFieldcallsquery$(() => props.id, load).get()):['a','a','a','a']. A parent that re-rendered before each load settled never revealed.['a'], and the boundary revealsv0.Changes
runtime.ts:restartUncommittedTrymoves the old primary's owners into the boundary's retry cache, and the replacement claims them by path.handOverSignalRetryScopewalk, reached only from this restart path, leaves the old scopes withfalse, an ownerless marker that still records retirement on deletion. It stops at a non-propagating nested boundary, assignalRetryBoundarydoes, because a nested primary claims only from its own cache. Those owners stay mapped and retire with the abandoned tree. Cursor Bugbot caught this on the third head. The handover can't rely on theRETAINED_SIGNAL_OWNERSwindow, because a root render defers a pre-existing block's teardown to its commit, after the replacement has claimed the owner.runtime.ts: on superseding inputs,supersedeSignalRetryOwnersprunes the cache instead of clearing it. It retires only owners whose cells cannot follow new inputs.signals/owner-context.ts: addssupersedeSignalOwner, an indirection the facade installs, so the runtime never imports the engine. It returns whether an owner can be kept; a kept owner's cells are marked provisional.signals/redeclaration.tsandScopeImpl.supersede(): a provisional cell was never presented by a committed render. Until a render that declares it is accepted, a discarded render's definition replaces the abandoned one, so a changed selection aborts the obsolete request as soon as the restarted attempt suspends. This keeps the existing contract insignals-pending-stream.test.ts("keeps pending inputs through parent renders before …"), which CI caught on the second head.signals/engine.tsandsignals/computations.ts: addScopeImpl.unkeyedState. An authoredsignal$sets it (in__signalAt), because its first initial value wins. ADerivedBindingsets it when its result turns asynchronous, because captured render values never restart that work. Those owners still restart with the attempt.docs/signals.md: states the contract. Adds a changeset (octanepatch).Validation
pnpm format:check: not run. Scopedpnpm format:files:checkon the changed files passes.pnpm typecheck: not run. Scopedpnpm typecheck:fileson the changed source and test files passes.pnpm test: not run. Left to CI.tests/suspense-parent-render-query.test.ts, 19 cases across.tsx,.tsrxJSX and compiled@try. 11 fail on main, including@trywhen an unrelated input changes. All pass with the fix, inoctaneandoctane-prod.signal$and asyncderived$guard cases go red when theirunkeyedStateflag is removed.tests/hydration/suspense-parent-render-query.test.ts, 4 cases (server'a', client'b', three parent renders). They fail on main+fix(signals): load the browser's own query selection over a seed for another request #1618 with['b','b','b','b']and pass with the fix. Like fix(hydration): keep a JSX boundary's query across retries and resume reads in returned JSX #1607's tests, they rely on fix(signals): load the browser's own query selection over a seed for another request #1618 (now merged) to hydrate a seed for another request.signals-pending-stream.test.tspasses inoctane-signalsafter the provisional-cell change (it failed 3/5 on head 4923078). On the merged head (with fix(hydration): discard the server tail after a last call adopted in place #1615), the D1 files, the local-selector files andreturned-jsx-query-resumepass inoctane(64 tests).octane(1,046 tests),octane-prod(785),octane-signals-node(166),octane-signals(150) andoctane-signals-prod(150). These cover fix(hydration): keep a JSX boundary's query across retries and resume reads in returned JSX #1607'sreturned-jsx-query-resume(including "restarts … for new children"), local selectors, signal instance identity,suspense.test.tsand transitions.run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes context,behavior-rootandbinding-apollo-clientall pass.root-chained-jsxis 86,002 B raw, the same as main. The first head was 22 B over because of adetachparameter on the sharedretainSignalRetryScope; that work now lives only on the restart path.Risk / follow-ups
derived$recomputes on every render, from fix(octane): re-select component-local query$ when captured props change #1550) is separate and not addressed here.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes Suspense retry and signal-owner lifecycle on a critical async rendering path, but behavior is narrowly scoped with extensive targeted tests.
Overview
Fixes a bug where a pending
<Suspense>boundary restarted itsquery$loads on every parent re-render (including equal JSX props or compiled@tryinput changes), so fast parent updates could leave the fallback up indefinitely; the same issue affected hydration when the client waited on an unresolved query.When an uncommitted attempt restarts, the runtime hands signal owners into the boundary retry cache and supersedes them instead of clearing everything:
query$cells stay and the new attempt re-selects—unchanged selection reuses the in-flight request, changed selection starts a new load and aborts the old one.signal$and asyncderived$are markedunkeyedStateand still restart with the attempt; provisional redeclaration keeps superseded query behavior correct when renders are discarded.Docs and a patch changeset describe the contract; client and hydration tests cover equal props, selection changes, unmount abort, and nested boundaries.
Reviewed by Cursor Bugbot for commit 1cc1eb1. Bugbot is set up for automated code reviews on this repo. Configure here.