Repository navigation
Description
A component-local derived value can remain pending after a dependency becomes ready during a held View Transition. The newly staged content is committed, but an event handler still observes the old pending snapshot.
Environment
Reproduced on main at fb404c24dfb81d2174303a5b1852d715b8479c79, Node 26.2.0, Vitest 4.1.11 and jsdom. This is a client-rendered test, using the repository's View Transition test mocks.
Reproduction
Save packages/octane/tests/_fixtures/waiter-staged-public.tsrx:
import { ViewTransition } from 'octane';
import { derived$, type SignalHandle } from 'octane/signals';
interface Props {
ready$: SignalHandle<boolean>;
waiting: Promise<void>;
version: number;
capture: (s: string) => void;
}
function Child(props: Props) @{
const value$ = derived$(({ read }) => {
void read;
if (!props.ready$.get()) throw props.waiting;
return 'ready:' + String(props.version);
});
const snapshot = value$.snapshot();
<section>
<button onClick={() => {
const current = value$.snapshot();
props.capture(current.status === 'ready' ? current.value : current.status);
}}>{props.version === 0 ? 'Short' : 'Much longer content here'}</button>
<output>{snapshot.status === 'ready' ? snapshot.value : snapshot.status}</output>
</section>
}
export function StagedWaiter(props: Props) @{
<ViewTransition update="auto">
<div><Child {...props} /></div>
</ViewTransition>
}Save packages/octane/tests/waiter-staged-public.test.ts:
import { expect, it } from 'vitest';
import { createRoot, flushSync, startTransition } from '../src/index.js';
import { createScope } from 'octane/signals';
import { act } from './_helpers.js';
import { installViewTransitionMocks } from './conformance/_helpers/view-transition-mocks.js';
import { StagedWaiter } from './_fixtures/waiter-staged-public.tsrx';
for (const updateBeforeAcceptance of [true, false]) {
it(`reflects a dependency update ${updateBeforeAcceptance ? 'before' : 'after'} staged acceptance`, async () => {
const mocks = installViewTransitionMocks();
const handles: Array<{ update: () => void | Promise<void>; finish: () => void }> = [];
(document as any).startViewTransition = (input: { update: () => void | Promise<void> } | (() => void)) => {
let finish!: () => void;
const pending = new Promise<void>((resolve) => { finish = resolve; });
handles.push({ update: typeof input === 'function' ? input : input.update, finish });
return { ready: pending, finished: pending, skipTransition() {} };
};
const scope = createScope({ scopeKey: 'staged' });
const ready$ = scope.signal$('ready', false);
const waiting = new Promise<void>(() => {});
const seen: string[] = [];
const container = document.createElement('div');
document.body.append(container);
const root = createRoot(container);
const props = { ready$, waiting, capture: (s: string) => seen.push(s) };
try {
await act(() => root.render(StagedWaiter, { ...props, version: 0 }));
expect(container.querySelector('output')?.textContent).toBe('pending');
await act(() => startTransition(() => root.render(StagedWaiter, { ...props, version: 1 })));
expect(handles).toHaveLength(1);
expect(container.querySelector('button')?.textContent).toBe('Short');
if (updateBeforeAcceptance) await act(() => ready$.set(true));
for (const handle of [...handles]) { await handle.update(); handle.finish(); }
await act(() => {});
expect(container.querySelector('button')?.textContent).toBe('Much longer content here');
if (!updateBeforeAcceptance) await act(() => ready$.set(true));
expect(ready$.get()).toBe(true);
flushSync(() => (container.querySelector('button') as HTMLButtonElement).click());
expect(seen.at(-1)).toBe('ready:1');
expect(container.querySelector('output')?.textContent).toBe('ready:1');
} finally {
for (const handle of handles) handle.finish();
flushSync(() => root.unmount());
scope.dispose();
container.remove();
mocks.restore();
}
});
}Save vitest.waiter-staged-public.config.mjs at the repository root:
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { defineConfig } from "vitest/config";
import { octane } from "./packages/octane/src/compiler/vite.js";
import { scopedSignalsProjects } from "./scripts/scoped-signals-projects.mjs";
const packageRoot = resolve("./packages/octane");
const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
const alias = Object.entries(pkg.exports).map(([name, target]) => ({
find: name === "." ? "octane" : "octane" + name.slice(1),
replacement: resolve(packageRoot, typeof target === "string" ? target : target.default),
})).sort((a, b) => b.find.length - a.find.length);
process.env.OCTANE_COMPILE_FROZEN_AST ??= "1";
process.env.OCTANE_COMPILE_ASSERT_LOC ??= "1";
export default defineConfig({ test: { projects: scopedSignalsProjects(octane)
.filter((p) => ["octane-signals", "octane-signals-prod", "octane-signals-strong"].includes(p.test?.name))
.map((p) => ({ ...p, root: resolve(packageRoot, "tests"), resolve: { alias },
test: { ...p.test, include: ["waiter-staged-public.test.ts"], exclude: [], setupFiles: [resolve(packageRoot, "tests/_per-test-setup.ts")], testTimeout: 6000 } })) } });Run:
pnpm exec vitest run --config vitest.waiter-staged-public.config.mjs --maxWorkers=1 --no-file-parallelismThe first case holds the browser's View Transition update callback, changes the dependency, and then releases the callback. The second case is a control which changes the same dependency after acceptance.
Expected: Both cases commit the changed content, and subsequent reads and rendering show ready:1.
Actual: In the before-acceptance case, the new button text is committed and the dependency is true, but the button reads pending. The after-acceptance control passes. This occurs in each of the development, production, and Strong compiler test configurations: three failing and three passing cases.
Investigation
A private declaration view is pending when rendered and its dependency changes before promotion. At the graph-operation level, promoting the invalidated view clears its dirty state; a later read can therefore return the stale pending state. A diagnostic change retaining this invalidation during promotion makes both cases pass in all three configurations. That experiment is not a proposed fix and does not establish safety for the other promotion lifecycles.
Activity
domgan-oai commentedon Oct 5, 2026
A staged render can commit a stale ready derived value when its new dependency changes before the transition update is accepted.
Verified on Octane main at
fb404c24dfb81d2174303a5b1852d715b8479c79, using the existing transition test helper and Vitest setup. The test replaces the derived computation's source while holding a view transition, changes the new source fromfalsetotrue, and accepts the transition.Expected: the rendered text and the retained derived signal both read
new. Actual: both remainold. As a control, movingnext$.set(true)to afterhandles[0].update()and transition completion updates both tonew.To reproduce, add these files to a checkout at the above commit and run:
packages/octane/tests/_fixtures/ready-view-held-1775.tsrxpackages/octane/tests/ready-view-held-1775.test.tsvitest.ready-view-held-1775.config.mjsfix(octane): re-evaluate a ready derived invalidated before a held tr…