Repository navigation
fix(octane): cancel a component's superseded query$ request read only by its pending @try arm - #1703
Merged
Merged
Conversation
…nder A query$ or derived$ cell is redeclared lazily when it is first read. When only a @Try arm read its component's declaration, the arm's attempt staged the new definition on its own nested capture. That attempt suspended and was discarded while the component committed, so the new selection was dropped and the previous request's AbortSignal stayed un-aborted until the component unmounted (#1697). A descriptor now records the render invocation that evaluated it. When a reader resolves the declaring owner's cell (the owner itself or one of its directive arms or inline rows), the redeclaration is staged with that invocation's stage and capture while it is still rendering. A component that receives the handle keeps staging its own cell in its own render. Fixes #1697 Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 4, 2026 15:16
3 of 6 tasks
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
50 other measured values are unchanged. Public-import reachability bundles (bytes)No changes across 105 measured values. |
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
Fixes #1697. A
query$declared in a committed component and read with.get()only inside that component's@try/@pendingboundary kept its superseded request live. The component committed the new selection, but the old request'sAbortSignalwas never aborted (and a stream's iterator never closed) until the component unmounted.Root cause. Signal facades are redeclared lazily, when a render first reads them. Here the only reader was the
@tryarm, so the arm staged the component's new definition on its own nested capture (the boundary's hidden reveal attempt). That attempt suspended on the new request and was discarded, which discarded the definition, even though the component's render, the one that evaluated the declaration, committed. The committed cell therefore stayed on the old selection. Asnapshot()read never suspends the arm, so its capture spliced into the root and committed, which is why the control in the issue behaved.Fix. A declaration now settles with the render that evaluated it, matching the #1530 ownership model, where arms own only the declarations they evaluate themselves.
Descriptorrecords the render invocation that evaluated it.readerOwner()),RedeclarableBinding.redeclareasks the renderer for that invocation's stage.query$, streamquery$, andderived$/scalarderived$shareRedeclarableBinding, so all of them follow this rule.Changes
signals/facade.ts,query-facade.ts,derived-facade.ts: the descriptor's declaring invocation is passed to cell creation only for the declaring owner's cell.signals/engine.ts,computations.ts,scalar-computations.ts: threaddeclaringthrough todeclared()/redeclare().signals/redeclaration.ts: the declaring invocation is the render identity for "first declaration wins", and it selects the stage.signals/read-protocol.ts,native-read-client.ts,runtime.ts: the stage resolver accepts the declaring invocation. Driver frames carryinvocationandcapture, and the capture is cleared atendRenderso a reused frame never retains it.enclosingInvocation(id)walks the frame stack and stops early.packages/octane/tests/suspense-committed-parent-query.test.ts(20 cases) covering both strong and default compiles, in dev (octane) and prod (octane-prod).octane.Validation
pnpm format:check: not run repo-wide (local test-load rule);pnpm format:files:checkon the changed files passed.pnpm typecheck: not run repo-wide;pnpm typecheck:fileson every changed source file and the new test passed.pnpm test: not run locally (local test-load rule); CI runs it.pnpm exec vitest run --project octane packages/octane/tests/suspense-committed-parent-query.test.tsgives 20/20 passing, and also 20/20 withOCTANE_TEST_COMPILE_MODE=prod. Onmain, 6 of the 20 fail:query$× strong/default: the oldAbortSignalis not aborted and the stream is not closed.derived$.get()case × strong/default: a dependency-driven restart reloads the staleAselection instead of the committedB.mainand this branch, as intended. They are neighbour controls:snapshot()control from the issue;derived$still does not restart on captured render values alone.flushSyncdrains, strong dev and prod compiles) also passes with the fix.pnpm syncproduced no changes.Risk / follow-ups
beginRendernow does two more field writes plus ahost.capture()call, andendRenderone more write. Each descriptor construction reads the declaration invocation once. The core runtime call site is byte-identical, so nobenchmarks/bundle-sizescenario changes. Per the local test-load rule I did not run benchmarks locally; CI bench and size gates cover this.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core signal redeclaration and render-frame staging on a hot path (
beginRender); behavior change is narrow but affects async query cancellation and derived restarts around suspense boundaries.Overview
Fixes #1697: when a component's
query$(or asyncderived$) is only read via.get()inside@try/@pending, a parent re-render that commits a new selection no longer leaves the previous in-flight request alive until unmount.What changed. Signal redeclarations now settle with the render invocation that evaluated the declaration, not the nested reader (e.g. a suspending
@tryarm). Descriptors record that invocation;RedeclarableBinding.redeclarepasses it through and resolves the declaration stage from the declaring frame's capture when that invocation is still on the stack. The native-read driver tracks per-frame invocation id and capture, addsenclosingInvocation, and clears capture onendRenderso reused frames do not leak commit state.Scope. Same plumbing for
query$, streamquery$, andderived$/scalar paths; child components that receive a handle still own their own cell. Addssuspense-committed-parent-query.test.ts(20 cases) and anoctanepatch changeset.Reviewed by Cursor Bugbot for commit 0d2aa4c. Bugbot is set up for automated code reviews on this repo. Configure here.