Repository navigation
fix(octane): abort pending queries whose owner a retried attempt replaces - #1783
Conversation
…aces A pending Suspense or @Try boundary keeps the owners of a discarded attempt in its retry cache until the same structural position renders again. A retried attempt that rendered a different key, component or arm there, or that removed the position, never released them, so their query$ requests stayed un-aborted until the boundary resolved. A scope's first render in a retry region now proves what the attempt renders where it has been. Its own path retires other occupants of its parent's component, child or branch slot, and each slot it created retires other occupants recorded there. A completed render also retires slots it did not create. Positions a suspended attempt has not reached keep their requests. Fixes #1764 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
7 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hydration deferral drops retry prune
- Captured the retryVisit in the hydration suspend closure and restored it to SIGNAL_RETRY_VISIT before the deferred renderBlock re-entry, so the resumed call finds and consumes the visit and pruneSignalRetryVisit runs normally.
Or push these changes by commenting:
@cursor push de309ca5b4
Preview (de309ca5b4)
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
@@ -11104,7 +11104,11 @@
(!hydration.owns(block) ||
(block.kind === 'dynamic' && block.endMarker !== null && hydration.rebuilds(block.endMarker)))
) {
- hydration.suspend(() => renderBlock(block));
+ const deferredVisit = retryVisit;
+ hydration.suspend(() => {
+ if (deferredVisit !== null) SIGNAL_RETRY_VISIT = deferredVisit;
+ renderBlock(block);
+ });
return;
}
const previousOwner = renderPhaseOwner;You can send follow-ups to the cloud agent here.
renderBlock takes a fresh scope's retry visit before deciding whether the active hydration owns the block. When it does not, the block renders through a nested hydration.suspend(() => renderBlock(block)) call, which found no visit and skipped pruning. Hand the visit to that nested render. 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.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Last slot skip blocks replacement prune
- Removed the last-slot exemption in pruneSignalRetryVisit because all slot creation paths assign identity fields (currentComp, branch, prevKey) before calling renderBlock, so the occupant is proven even when the body suspends mid-render.
Or push these changes by commenting:
@cursor push cdfdb5424c
Preview (cdfdb5424c)
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
@@ -865,9 +865,10 @@
// been. Its own path ends in the occupant identity of its parent's slot when
// that segment is ['slot', index, kind, branch, component, key]; item and
// scope segments cannot place a sole kind there. Every slot it created holds
-// this attempt's occupant, except one still rendering when it suspended. A
-// completed render that created no slot at an index renders nothing there; a
-// suspended one may not have reached it yet.
+// this attempt's occupant — identity fields (branch, currentComp, prevKey) are
+// assigned before the slot's body renders, so the occupant is proven even when
+// the body suspends mid-render. A completed render that created no slot at an
+// index renders nothing there; a suspended one may not have reached it yet.
function pruneSignalRetryVisit(visit: SignalRetryVisit, suspended: boolean): void {
const { scope, cache, path } = visit;
const retired: SignalRendererOwnerIdentity[] = [];
@@ -880,8 +881,6 @@
retired,
);
const slots = signalRetryNode(cache, path, false)?.children?.get('slot')?.children;
- const created = scope._slots;
- const rendering = suspended ? created?.[created.length - 1] : undefined;
if (slots !== undefined) {
for (const [index, node] of slots) {
const slot = scope.slots[index as number];
@@ -889,7 +888,7 @@
if (suspended) continue;
slots.delete(index);
collectRetiredSignalRetryOwners(node, cache, retired);
- } else if (slot !== rendering && signalRetrySoleKind(slot.__kind)) {
+ } else if (signalRetrySoleKind(slot.__kind)) {
collectReplacedSignalRetryOccupants(
node,
slot.forSlot != nullYou can send follow-ups to the cloud agent here.
A fresh componentSlot, childSlot, ifBlock or switchBlock records its occupant identity before it renders that occupant, and a childSlot unwraps a thenable before it registers. Every slot a suspended first render created therefore holds its final identity, including one still rendering, so pruning no longer skips the last-created slot. The added test pins the neighbouring rule: a hole the render has not reached keeps its request until the completed attempt renders without it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Budgets move by the measured esbuild-to-Oxc difference on the same source (budget - max(0, esbuild - oxc)), so the methodology change lowers 131 values, keeps 28, raises none, and leaves the headroom #1782 granted to #1783 in place. The baseline, ratio guards and website summary are recomputed from the merged source. 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: Lite scopes never prune retry owners
- Fixed by adding retry-visit claim/prune logic to componentSlotLite (mirroring renderBlock) and changing the mounted check in scopeSignalOwner from scope.block.mounted to scope.mounted so LiteBlockImpl scopes correctly gate visit creation to first render only.
Or push these changes by commenting:
@cursor push 1fdc657e12
Preview (1fdc657e12)
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
@@ -1181,7 +1181,7 @@
node.owner = undefined;
cache.owners.delete(owner);
}
- if (path !== null && !scope.block.mounted) visit = { scope, cache, path };
+ if (path !== null && !scope.mounted) visit = { scope, cache, path };
}
if (owner === undefined || owner.documentOwner !== documentOwner) {
const instanceKey = resolveSignalInstanceKey(scope);
@@ -12152,18 +12152,25 @@
let claimed: Node | null | undefined;
const outerClaim =
adoptedOpen === null ? undefined : hydration!.beginClaim(getNextSibling(adoptedOpen));
+ let retryVisit: SignalRetryVisit | null = null;
try {
if (signalDocumentEnabled || scope.block.idState.renderOwner?.signalOwner !== undefined) {
// Same owner-resolution order as runWithBlockSignalOwner, but the
// per-mount closure only exists when the owner actually changes.
const owner = scopeSignalOwner(scope);
if (owner !== undefined) STREAMED_SIGNAL_OWNER_ACTIVATOR?.(owner);
+ if (SIGNAL_RETRY_VISIT !== null) {
+ if (SIGNAL_RETRY_VISIT.scope === scope) retryVisit = SIGNAL_RETRY_VISIT;
+ SIGNAL_RETRY_VISIT = null;
+ }
if (owner === undefined || currentSignalOwner() === owner) {
comp(props, scope, undefined);
} else runWithSignalOwner(owner, () => comp(props, scope, undefined));
} else comp(props, scope, undefined);
+ if (retryVisit !== null) pruneSignalRetryVisit(retryVisit, false);
if (!scope.mounted) scope.mounted = true;
} catch (error) {
+ if (retryVisit !== null && isSuspenseException(error)) pruneSignalRetryVisit(retryVisit, true);
profileDidThrow = true;
profileThrown = error;
throw error;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit a0b029b. Configure here.
A hookless same-module component renders as a lite scope rather than a Block. scopeSignalOwner recorded its retry visit, but only renderBlock took visits, so a lite wrapper that stopped rendering a pending query$ left it in flight until the boundary resolved. The lite path now takes its visit and prunes once its body completes or suspends. A visit is recorded for a scope that has not mounted, not one whose block has not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…1794) #1783 now also prunes retry owners from a lite component's first render (Bugbot review). Measured on main 2f88235 with #1783 merged in, that moves seven gzip budgets past their 32-byte headroom. Co-authored-by: Claude Opus 5.5 <[email protected]>
#1783 landed and spent the headroom #1782/#1793/#1794 granted it. Each budget is again main's value minus the measured esbuild-to-Oxc difference on the merged source (131 lowered, 28 unchanged, none raised). The baseline record, home summary and refresh note follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er fix (#1797) #1781 lands #1774's children signal owner and the Hydrate children fix on top of main c3c0a3b. #1773's raises for #1774 were used up by #1783's budgets (#1793, #1794), which were sized without #1774's code. Measured on main + #1781: 69 values breach, all raw or gzip; brotli fits everywhere. Each breached value goes to measured + 32; no other value moves. Co-authored-by: Claude Opus 5.5 <[email protected]>
* ci(bench): measure bundle sizes with Vite 8's default minifier The bundle-size and bundle-reachability harnesses forced Vite's `minify: 'esbuild'`. That mode turns Rolldown's own minifier off, and with it the dead-code elimination that removes branches guarded by a never-written module flag, so the numbers were not what a Vite app ships. - run.mjs builds every framework with `minify: 'oxc'` (Vite 8's default client minifier), still identical settings for every target. - run-minimal.mjs builds its Vite scenarios with `'oxc'`; the esbuild bundler scenarios keep esbuild's `minify: true`. The async-identity encoder check accepts Oxc's template-literal quotes. - Every budget is ratcheted down (144 lowered, 15 unchanged, 0 raised), the bundle-size baseline is re-recorded, the 18 cross-framework ratio guards are re-cut, and the website summary and copy follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-measure the Oxc budgets on main with #1761 and #1782 Budgets move by the measured esbuild-to-Oxc difference on the same source (budget - max(0, esbuild - oxc)), so the methodology change lowers 131 values, keeps 28, raises none, and leaves the headroom #1782 granted to #1783 in place. The baseline, ratio guards and website summary are recomputed from the merged source. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(website): compare home summary ceilings at stable precision The smoke test rounds each summary row to 15 significant digits because Math.log/exp can differ by one ULP between libc implementations, but it compared the bundle-size range ends exactly. Those ends are geometric means too: the recorded Solid ceiling was 0.9500824085923075 on macOS and 0.9500824085923076 on the Linux runner. Round them the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-derive the Oxc budgets on main with #1766, #1768, #1770, #1772 and #1794 Same method as before: each budget is main's value minus the measured esbuild-to-Oxc difference on the merged source, never raised (131 lowered, 28 unchanged). The baseline record and home summary follow the new bytes; every ratio guard still holds with the ceilings already cut. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-derive the Oxc budgets on main with #1783 #1783 landed and spent the headroom #1782/#1793/#1794 granted it. Each budget is again main's value minus the measured esbuild-to-Oxc difference on the merged source (131 lowered, 28 unchanged, none raised). The baseline record, home summary and refresh note follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-cut the cross-framework ratio guards after #1784 With #1784's hydrating flag folded by Oxc, Octane's totals shrink 8.5-10% instead of about 5%, so the total-gzip ceilings had grown about 6% loose. They are re-cut at about 1.5% headroom on the merged-source measurement; application-code ceilings are unchanged. All 72 bundle-size guards hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
Fixes #1764. A pending
query$request is now aborted when its owner is replaced or removed while a<Suspense>or@tryboundary is still pending. The pending outer request, surviving owners, and places the attempt has not reached keep their requests.Root cause. When an uncommitted primary restarts with new inputs,
restartUncommittedTrymoves its owners into the boundary's retry cache, keyed by structural path.discardSignalRetryItemand suspended WIPs do the same.supersedeSignalRetryOwnerskeeps everyquery$owner, because a redeclared query can re-select from new inputs. The retried attempt then claims only the paths it renders again. Nothing released entries whose position now held something else:.tsrx, a keyed child sits in acomponentSlotwhose path ends inprevKey. A key-only change claimed a new path and left the old key's owner cached until the boundary resolved. TSX passed only because a keyed single child goes through the list path, wheretrackSignalRetryListKeysprunes absent keys.<b>instead, so nothing claimed or pruned them.Changes
packages/octane/src/runtime.ts: when a scope consults a retry cache on its first render (!mounted),scopeSignalOwnerrecords a visit.renderBlocktakes the visit and prunes once that render completes or suspends:['slot', i, kind, branch, component, key]), the attempt has proven which occupant that slot holds. Retained occupants with a different kind, branch, component or key are retired. Try slots, which hold a primary beside a fallback, and list rows, which prune by key, are left alone.The trie is edited fully before any owner retires, as
trackSignalRetryListKeysdoes, so abort callbacks cannot observe a half-pruned cache. Pruning runs only for scopes in their first render. In-place retries of a hidden primary and committed scopes never prune, so a held transition's retained owners are untouched.If the active hydration doesn't own the block,
renderBlockbuilds it through a nestedhydration.suspend(() => renderBlock(block))call, and hands the visit to that nested render (from Bugbot review). No public-API scenario I tried reaches this path with a visit, so it has no dedicated test.A hookless same-module component renders as a lite scope rather than a Block. Its render path takes and prunes the visit the same way (from Bugbot review).
docs/signals.mdnow states this in the query lifetime contract.Validation
pnpm exec vitest run packages/octane/tests/pending-query-owner-retirement.test.ts --project octane: 30/30 pass.<Suspense>and@try, dev/prod × client/hydration; nested removal, dev/prod.@ifarm swap and component swap with a later suspending sibling.pnpm typecheck:filesandpnpm format:files:checkon the changed files;pnpm syncis clean.node benchmarks/bundle-size/run-minimal.mjsandrun.mjs: +0.9–1.1 kB raw / +0.3–0.45 kB gzip per client bundle. The raises are in ci(bench): raise byte budgets for pending query owner retirement #1782 (merged), ci(bench): raise byte budgets for the pending query owner fix on top of #1761 #1793 (combined growth with fix(octane): resolve a component's signal handles from its nested@{ … }blocks #1761, merged) and ci(bench): raise byte budgets for lite-scope retry pruning in #1783 #1794 (lite-scope pruning).pnpm format:check,pnpm typecheck,pnpm test: left to CI to keep local load down. No local benchmark timing run either.Risk / follow-ups
renderBlockgains one local plus null checks inside the existing signal-enabled branch. The pruning itself runs only while a retry cache exists.renderBlockreaches. Gating that machinery belongs with the runtime reachability work (perf(octane): stop shipping the signal binding runtime in apps without signals #1762).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 core Suspense retry-owner pruning and async
query$cancellation during uncommitted renders; behavior is nuanced but covered by a large targeted test matrix.Overview
Pending
query$requests are now aborted when a retried Suspense/@tryattempt replaces or removes their owner (key-only child change,@if/component swap, nested boundary removal), instead of keeping the old in-flight request until the boundary resolves.The Octane runtime records a signal-retry visit on a scope’s first render when it claims from the boundary retry cache, then
pruneSignalRetryVisitafter that render finishes or suspends: it drops retry-cache occupants that no longer match what the attempt rendered at sole-occupant slots (component/child/@if/@switch), while not pruning places the attempt has not reached yet or owners that render again with the same identity.docs/signals.mdand a changeset document the contract;pending-query-owner-retirement.test.tscovers TSX/TSRX/@try, hydration, and retention guards.Reviewed by Cursor Bugbot for commit 1628ec4. Bugbot is set up for automated code reviews on this repo. Configure here.