Repository navigation
Description
A local query$ declared in a committed parent can keep a superseded pending request alive when its value is read with .get() inside @try / @pending. The new selection and its pending fallback commit, but the previous request's AbortSignal remains un-aborted. In a longer check, the old request was still live after the new selection resolved; unmounting the owner finally aborted it.
The query documentation says selecting a new argument cancels obsolete work. As a control, replacing the strict read with snapshot() aborts the old pending request in the same selection sequence. An existing suspense test covers a query declared inside the pending boundary; this reproduction declares the query in its committed parent.
Reproduction
Observed using the public source for Octane 0.9.0 at 76b5b026713cbdc153b0d6786c1b1ecc952e8893, Node 26.2.0, Vitest 4.1.11, and jsdom. Both Strong development and production compilation reproduce it. The source was tested; the published npm tarball was not independently compared.
In an Octane checkout at that commit, install its dependencies, save the following two files, and run from the checkout root:
pnpm exec vitest run --config query-pending-cancellation-repro.config.mjsThe component commits B with the pending fallback, and both A and B loaders have run. The final assertion expects A's signal to be aborted. It fails with expected false to be true in both modes. A similar standalone control also reproduces the behavior for stream queries.
packages/octane/tests/query-pending-cancellation-repro.test.ts
import { expect, it } from 'vitest';
import { createRoot, flushSync } from 'octane';
import * as signals from 'octane/signals';
import { loadCompiledFixtureSource } from './_server-fixture.js';
const source = `import { useLayoutEffect } from 'octane';
import { query$ } from 'octane/signals';
export function App(props) @{
const result$ = query$(() => props.selection, props.load);
useLayoutEffect(() => { props.onCommit(props.selection); });
<main>
<span>{props.selection as string}</span>
@try { <p>{result$.get() as string}</p> }
@pending { <p>pending</p> }
</main>
}`;
for (const dev of [true, false]) {
it(`cancels a superseded pending selection (dev=${dev})`, async () => {
const { App } = loadCompiledFixtureSource(source, {
id: '/query-pending-cancellation.tsrx',
mode: 'client',
compileOptions: { strong: true, dev, hmr: false },
runtimeModules: { 'octane/signals': signals },
});
const calls: Array<{ selection: string; signal: AbortSignal }> = [];
const load = (selection: string, { signal }: { signal: AbortSignal }) =>
new Promise<string>(() => { calls.push({ selection, signal }); });
const commits: string[] = [];
const onCommit = (selection: string) => { commits.push(selection); };
const host = document.createElement('div');
const root = createRoot(host);
const drain = async () => {
for (let n = 0; n < 12; n++) {
await Promise.resolve();
flushSync(() => {});
}
};
try {
root.render(App, { selection: 'A', load, onCommit });
flushSync(() => {});
await drain();
root.render(App, { selection: 'B', load, onCommit });
flushSync(() => {});
await drain();
expect(commits).toEqual(['A', 'B']);
expect(host.querySelector('span')?.textContent).toBe('B');
expect(host.querySelector('p')?.textContent).toBe('pending');
expect(calls.map((call) => call.selection)).toEqual(['A', 'B']);
expect(calls[0].signal.aborted).toBe(true);
} finally {
root.unmount();
}
});
}query-pending-cancellation-repro.config.mjs
import path from 'node:path';
const src = path.resolve('packages/octane/src');
export default {
resolve: { alias: [
{ find: /^octane$/, replacement: `${src}/index.ts` },
{ find: /^octane\/internal\/client$/, replacement: `${src}/internal/client.ts` },
{ find: /^octane\/internal\/server$/, replacement: `${src}/internal/server.ts` },
{ find: /^octane\/compiler$/, replacement: `${src}/compiler/index.js` },
{ find: /^octane\/signals$/, replacement: `${src}/signals/index.ts` },
] },
test: { include: ['packages/octane/tests/query-pending-cancellation-repro.test.ts'], environment: 'jsdom' },
};
Activity
fix(octane): stage a component's query$ redeclaration with its own re…