Skip to content

Commit b7544c6

Browse files
committed
fix(signals): a first load in flight stays loading through an identity memo, a derived store and isPending
- E2/E3 (async-gen seed 91501 #504): a lane's dissolution no longer commits an empty `_value` for a first load the lane produced nothing for whose own flight is up (now whether or not its inputs were published), nor for a node pending on such a load (an identity memo of it, a derived store's derive). `latest()` of the identity memo or the store's key is loading, as the direct read is (D-22). - #156: `isPending()` of a first load in flight in a verdict lane is loading (A19 exc. 1), as `latest()` of it is; the boundary keeps its fallback instead of revealing a leaf whose effect then throws. A re-ask of a load an error answered first stays pending (D-41, #4375). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent 07d7b19 commit b7544c6

5 files changed

Lines changed: 233 additions & 21 deletions

File tree

‎packages/signals/docs/RULES-INDEX.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
6363
| A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:221` | scheduler.ts×1 | spec-async-semantics.test.ts×1 strict-read-pending-store.test.ts×2 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×2 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B5)] `isPending` never throws in untracked contexts — (was B5) `isPending` never throws in untracked contexts — thunks that throw real errors or read… |
6464
| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:71` | async.ts×3 constants.ts×1 lanes.ts×7 scheduler.ts×2 verdict.ts×1 map.ts×1 optimistic.ts×1 store.ts×3 | create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×6 lane-uninitialized-landing-3648.test.ts×5 optimistic-over-held-row-3796.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×2 optimistic-undefined-override.test.ts×1 posture-store-parity.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×2 kanban-a17-fixture.test.ts×3 optimistic-list-mutation-matrix.test.ts×1 optimistic-maparray-index-frame-f1.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.states.ts×24 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×20 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from C4)] An active override is the displayed value until its transaction commits, and the graph's value until its own source answers — **Statement (curre… |
6565
| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:81` | action.ts×1 async.ts×2 core.ts×3 lanes.ts×8 scheduler.ts×2 types.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×1 projection.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×3 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×4 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×5 flight-owned-transaction.test.ts×1 lane-authority-twins.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 unchanged-presence-no-hold-3743.test.ts×2 superseded-before-first-commit.test.ts×4 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×19 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from B4)] An override lives exactly as long as its own transaction; a newer truth from the source supersedes it in the graph immediately, on screen at com… |
66-
| A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:149` | async.ts×1 constants.ts×1 core.ts×6 scheduler.ts×2 types.ts×1 verdict.ts×4 store.ts×2 | create-deferred-3710.test.ts×2 derived-store-first-landing-verdict.test.ts×1 fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 mount-over-foreign-hold-3761.test.ts×2 spec-async-semantics.test.ts×3 derived-presence-async-3726.test.ts×2 superseded-before-first-commit.test.ts×3 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×14 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPendi… |
66+
| A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:149` | async.ts×1 constants.ts×1 core.ts×6 lanes.ts×1 scheduler.ts×2 types.ts×1 verdict.ts×5 store.ts×2 | create-deferred-3710.test.ts×2 derived-store-first-landing-verdict.test.ts×1 fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 latest-memo-inline-parity.test.ts×1 mount-over-foreign-hold-3761.test.ts×2 spec-async-semantics.test.ts×3 derived-presence-async-3726.test.ts×2 superseded-before-first-commit.test.ts×3 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×14 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPendi… |
6767
| A20 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:408` | — | question-scoped-pending.test.ts×2 spec-async-semantics.test.ts×3 createOptimisticStore.test.ts×1 | [superseded 2026-07-13 by A24] (superseded) Optimistic writes announce a store-wide pending — (**SUPERSEDED 2026-07-13 by A24** — the mask is deleted; optimistic writes are verdict-inert. Kept for the… |
6868
| A21 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:415` | — | question-scoped-pending.test.ts×3 spec-async-semantics.test.ts×3 | [superseded 2026-07-13 by A24] (superseded) The store-wide mask — (**SUPERSEDED 2026-07-13 by A24** — the store-wide mask is deleted with the mask model; nothing silences a new question. The effective… |
6969
| A22 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:229` | store.ts×1 | createProjection.draft-lifetime-3585.test.ts×1 spec-async-semantics.test.ts×1 visibility-oracle-store.states.ts×1 | [ruled, amended in place 2026-07-08] Pending is per-node; store-wide only for the firewall's own work — **Pending is per-node: store-wide verdicts exist only as the firewall's own in-flight work (A9) … |

‎packages/signals/src/core/lanes.ts‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ function dissolveLane(l: Transaction, into: Transaction | null, except?: Signal<
508508
l._verdict = null;
509509
if (lanes.indexOf(v) !== -1) dissolveLane(v, null);
510510
}
511+
// First loads this dissolution leaves loading (below).
512+
const loading: Computed<any>[] = [];
511513
for (let i = 0; i < l._nodes.length; i++) {
512514
const n = l._nodes[i];
513515
const x = n._x!;
@@ -543,22 +545,23 @@ function dissolveLane(l: Transaction, into: Transaction | null, except?: Signal<
543545
// lane's answer beside inputs that are the truth now: a fresh reader
544546
// of its flight observes it (#3648, #3651; #3305's commit beneath a
545547
// flight).
546-
// Not a first load whose own flight is up and already observed (its
547-
// inputs published beneath it) with nothing produced in the lane:
548-
// committing its empty `_value` would initialize it as `undefined`,
549-
// and `latest()` would serve that. It stays loading until its flight
550-
// answers (D-22; async-gen seed 3289 #929).
548+
// Not a first load the lane produced nothing for whose own flight is
549+
// up, nor one pending on such a load kept here (an identity memo of
550+
// it, a derived store's derive): committing its empty `_value` would
551+
// initialize it as `undefined`, which `latest()` would serve and
552+
// `isPending()` call pending. It stays loading until its flight
553+
// answers (D-22, A19 exc. 1; async-gen 3289 #929, 91501 #504, #156).
551554
x._transaction = null;
552555
if (
553-
!effect &&
554-
!guess &&
555-
(slot !== NOT_PENDING ||
556-
!x._inFlight ||
557-
!(n._config & CONFIG_INPUTS_PUBLISHED) ||
558-
((n as Computed<any>)._statusFlags & (STATUS_UNINITIALIZED | STATUS_PENDING)) !==
559-
(STATUS_UNINITIALIZED | STATUS_PENDING))
560-
)
561-
n._pendingValue = latest;
556+
effect ||
557+
guess ||
558+
slot !== NOT_PENDING ||
559+
((n as Computed<any>)._statusFlags & (STATUS_UNINITIALIZED | STATUS_PENDING)) !==
560+
(STATUS_UNINITIALIZED | STATUS_PENDING) ||
561+
!(x._inFlight || loading.some(q => x._pendingSources?.has(q)))
562+
) {
563+
if (!effect && !guess) n._pendingValue = latest;
564+
} else loading.push(n as Computed<any>);
562565
commitPendingNode(n);
563566
if (!effect) {
564567
if (

‎packages/signals/src/core/verdict.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,20 @@ function verdictValue(el: Signal<any> | Computed<any>, c: Computed<any> | null):
415415
if (latestActive && l.folded) return l.folded(null, el);
416416
return el._x!._lane;
417417
}
418-
if (probing && flying) probeFound = true;
419-
if (!latestActive) return display(el);
420418
const v = flying ? display(el) : laneValueOf(el);
421-
// A first load in flight with nothing produced yet: loading (D-22).
422-
if (flying && v === el._value && owner._statusFlags & STATUS_UNINITIALIZED)
419+
// A first load in flight with nothing produced yet: loading, for
420+
// `latest` (D-22) as for `isPending` (A19 exc. 1) — unless an error
421+
// answered it first: its re-ask is pending, the error its display
422+
// (D-41, #4375).
423+
if (
424+
flying &&
425+
v === el._value &&
426+
owner._statusFlags & STATUS_UNINITIALIZED &&
427+
(latestActive || !owner._x!._shownError)
428+
)
423429
throw owner._x!._error;
424-
return v;
430+
if (probing && flying) probeFound = true;
431+
return latestActive ? v : display(el);
425432
}
426433
// Dev strict-read scopes (a component body, an effect callback) warn on a
427434
// verdict read as on any untracked read; the pending throw they add for a

‎packages/signals/tests/latest-memo-inline-parity.test.ts‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import {
2424
createRenderEffect,
2525
createRoot,
2626
createSignal,
27+
createStore,
2728
flush,
29+
isPending,
2830
latest
2931
} from "../src/index.js";
3032

@@ -294,3 +296,112 @@ describe("C4: a render effect born in a held pass beside the committed frame's [
294296
dispose();
295297
});
296298
});
299+
300+
// E2/E3 twins of the first-load rule (async-gen seed 91501 #504): the leaf
301+
// reads `latest(view)` where `view` is the async derivation itself, an
302+
// identity memo of it, or a derived store's `v` over it. Its first load is
303+
// in flight in a verdict lane and has produced nothing: loading in all three
304+
// (D-22) — the boundary keeps its fallback. Before, the lane's dissolution
305+
// committed the identity memo (pending on that load, no flight of its own)
306+
// as `undefined`, and `latest()` served it.
307+
describe("latest() of a first load in flight read through an identity memo or a derived store is loading", () => {
308+
for (const view of ["direct", "identity", "store"] as const)
309+
it(view, async () => {
310+
const seen: string[] = [];
311+
const resolvers: (() => void)[] = [];
312+
let set!: (v: number) => void;
313+
const dispose = createRoot(d => {
314+
const [s, _set] = createSignal(0);
315+
set = _set;
316+
const m0 = createMemo(() => 1 + latest(s) + s());
317+
const m1 = createMemo(() => {
318+
const v = 1 + latest(m0) + m0();
319+
return new Promise<number>(r => resolvers.push(() => r(v)));
320+
});
321+
let read: () => number | undefined = m1;
322+
if (view === "identity") read = createMemo(() => m1());
323+
else if (view === "store") {
324+
const [store] = createStore<{ v?: number }>(d => {
325+
d.v = m1();
326+
}, {});
327+
read = () => store.v;
328+
}
329+
const b = createLoadingBoundary(
330+
() => {
331+
// One hole each, as a compiled leaf has them.
332+
createRenderEffect(
333+
() => `lm1:${latest(read)}`,
334+
v => void seen.push(v)
335+
);
336+
createRenderEffect(s, () => {});
337+
createRenderEffect(
338+
() => latest(s),
339+
() => {}
340+
);
341+
return "content";
342+
},
343+
() => "[L]"
344+
);
345+
createRenderEffect(b, v => void seen.push(`view=${v}`));
346+
return d;
347+
});
348+
flush();
349+
expect(seen).toEqual(["view=[L]"]);
350+
set(2);
351+
await tick();
352+
expect(seen).toEqual(["view=[L]"]);
353+
expect(seen.some(x => x.includes("undefined"))).toBe(false);
354+
resolvers.forEach(r => r());
355+
await tick();
356+
expect(seen.slice(1).sort()).toEqual(["lm1:11", "view=content"]);
357+
dispose();
358+
});
359+
});
360+
361+
// async-gen seed 91501 #156: `isPending(m0)` of a first load in flight in a
362+
// verdict lane is loading, as `latest()` of it is (A19 exc. 1, D-22): the
363+
// boundary keeps its fallback until a load lands. Before, the lane pass
364+
// answered `true` and the boundary revealed; the pass after the lane's
365+
// dissolution (the load kept uninitialized) threw, and the revealed leaf
366+
// never ran.
367+
describe("isPending() of a first load in flight in a verdict lane is loading", () => {
368+
it("the boundary keeps its fallback until the load lands", async () => {
369+
const seen: string[] = [];
370+
const flights: { v: number; settle: () => void }[] = [];
371+
let set!: (v: number) => void;
372+
const dispose = createRoot(d => {
373+
const [s, _set] = createSignal(0, { ownedWrite: true });
374+
set = _set;
375+
const m0 = createMemo(() => {
376+
const v = 1 + latest(s);
377+
return new Promise<number>((res, rej) =>
378+
flights.push({ v, settle: () => (v === 1 ? rej(new Error("m0:1")) : res(v)) })
379+
);
380+
});
381+
const b = createLoadingBoundary(
382+
() => {
383+
createRenderEffect(
384+
() => `ls:${latest(s)} pm:${isPending(m0)}`,
385+
v => void seen.push(v)
386+
);
387+
return "content";
388+
},
389+
() => "[L]"
390+
);
391+
createRenderEffect(b, v => void seen.push(`view=${v}`));
392+
return d;
393+
});
394+
flush();
395+
set(3);
396+
await new Promise(r => setTimeout(r, 0));
397+
flush();
398+
expect(seen).toEqual(["view=[L]"]);
399+
flights.shift()!.settle();
400+
await tick();
401+
expect(seen).toEqual(["view=[L]"]);
402+
flights.shift()!.settle();
403+
await tick();
404+
expect(seen).toEqual(["view=[L]", "ls:3 pm:false", "view=content"]);
405+
dispose();
406+
});
407+
});

‎packages/web/test/latest-memo-inline-parity.spec.tsx‎

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
// (`L = createMemo(() => latest(x))`) show the same screen (F-6, D-25, D-26).
77
// The signals-side pins are `packages/signals/tests/latest-memo-inline-parity.test.ts`.
88
import { describe, expect, test } from "vitest";
9-
import { action, createMemo, createOptimistic, createSignal, flush, latest } from "solid-js";
9+
import {
10+
Errored,
11+
Loading,
12+
action,
13+
createMemo,
14+
createOptimistic,
15+
createSignal,
16+
createStore,
17+
flush,
18+
isPending,
19+
latest
20+
} from "solid-js";
1021
import { render } from "../src/index.js";
1122

1223
async function tick() {
@@ -80,3 +91,83 @@ describe("a plain write beside an async memo: the screen beside latest(), inline
8091
dispose();
8192
});
8293
});
94+
95+
// async-gen seed 91501 #504 (E2/E3): `latest()` of an async derivation's
96+
// first load in flight — read directly, through an identity memo, or through
97+
// a derived store — is loading (D-22): the boundary keeps its fallback, and
98+
// no hole shows `undefined`.
99+
describe("latest() of a first load in flight: direct, identity memo, derived store", () => {
100+
for (const view of ["direct", "identity", "store"] as const)
101+
test(view, async () => {
102+
const div = document.createElement("div");
103+
const resolvers: (() => void)[] = [];
104+
const [s, set] = createSignal(0, { ownedWrite: true });
105+
const dispose = render(() => {
106+
const m0 = createMemo(() => 1 + latest(s) + s());
107+
const m1 = createMemo(() => {
108+
const v = 1 + latest(m0) + m0();
109+
return new Promise<number>(r => resolvers.push(() => r(v)));
110+
});
111+
let read: () => number | undefined = m1;
112+
if (view === "identity") read = createMemo(() => m1());
113+
else if (view === "store") {
114+
const [store] = createStore<{ v?: number }>(d => {
115+
d.v = m1();
116+
}, {});
117+
read = () => store.v;
118+
}
119+
return (
120+
<Loading fallback="[L]">
121+
<span data-l={`lm1:${latest(read)}`}>
122+
{s()} {latest(s)}
123+
</span>
124+
</Loading>
125+
);
126+
}, div);
127+
flush();
128+
expect(div.innerHTML).toBe("[L]");
129+
set(2);
130+
await tick();
131+
expect(div.innerHTML).toBe("[L]");
132+
resolvers.forEach(r => r());
133+
await tick();
134+
expect(div.innerHTML).toBe('<span data-l="lm1:11">2 2<!----></span>');
135+
dispose();
136+
});
137+
});
138+
139+
// async-gen seed 91501 #156: `isPending()` of a first load in flight is
140+
// loading (A19 exc. 1): the boundary keeps its fallback until a load lands,
141+
// rather than revealing a span whose attribute effect is still loading.
142+
test("isPending() of a first load in flight keeps the boundary's fallback", async () => {
143+
const div = document.createElement("div");
144+
const flights: (() => void)[] = [];
145+
const [s, set] = createSignal(0, { ownedWrite: true });
146+
const dispose = render(() => {
147+
const m0 = createMemo(() => {
148+
const v = 1 + latest(s);
149+
return new Promise<number>((res, rej) =>
150+
flights.push(() => (v === 1 ? rej(new Error("m0:1")) : res(v)))
151+
);
152+
});
153+
return (
154+
<Errored fallback="[E]">
155+
<Loading fallback="[L]">
156+
<span data-a={`ls:${latest(s)}`} data-b={`pm:${isPending(m0)}`} />
157+
</Loading>
158+
</Errored>
159+
);
160+
}, div);
161+
flush();
162+
expect(div.innerHTML).toBe("[L]");
163+
set(3);
164+
await tick();
165+
expect(div.innerHTML).toBe("[L]");
166+
flights.shift()!();
167+
await tick();
168+
expect(div.innerHTML).toBe("[L]");
169+
flights.shift()!();
170+
await tick();
171+
expect(div.innerHTML).toBe('<span data-a="ls:3" data-b="pm:false"></span>');
172+
dispose();
173+
});

0 commit comments

Comments
 (0)