Skip to content

Commit 7c9fad9

Browse files
committed
Merge remote-tracking branch 'origin/next' into claude/tmp-4522
# Conflicts: # scripts/size/scenarios.js
2 parents e849972 + 25b94f0 commit 7c9fad9

12 files changed

Lines changed: 292 additions & 56 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
An async memo over two verdict memos asks each question once, and a lane's readers show its answer together (#4408, #4399; F-6, F-9, D-25, D-26).
6+
7+
- An async memo with no verdict window of its own that waits on a source's flight as the hold's work (`holdWork`) drops its verdict posture at the wait, so the source's verdict-lane re-derive does not move it into that lane early, and the pass the landing runs reads plainly. Before, `latest(m2)` showed `c1101` while `m1:1122` of the same lane was still in flight.
8+
- A held memo's pass that re-entered its hold at its head stays that hold's work when it reads another hold's verdict lane, in either read order. Before, moved into the other lane, it read its own hold's landing as the screen and asked `m1:15` a second time.
9+
- A memo with a committed value and no pass staged keeps the verdict posture it reads when a pass of it reads that verdict memo while it is pending (#4408 after #4504; D-25). #4504's rule — a pending read hands on no posture — stays for the hold's own work: a pass born in the hold's world, or one over a staged pass of its own. Before, `m2 = m0b() + 1` lost its posture at such a read, re-ran plainly into the frame `m0b`'s answer landed in, and `latest(m2)` showed `c1101` before `v1122`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
A reader of a derived store whose derive carries a staged error (D-41) now links to the derive, as a reader of a pending or errored one does, so it re-runs when the derive's source answers. An `<Errored>` mounted in the change that errored its content over a keyed `createProjection` showed its fallback for good; it now shows the answer.

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,17 +2103,31 @@ export function read<T>(el: Signal<T> | Computed<T>): T {
21032103
// verdict now. Not an effect: a render effect is a frame reader
21042104
// already, and a user effect's posture is its own reads'.
21052105
// A read of a pending node hands on no posture to a pass that is
2106-
// not a verdict reader already (#4504): such a read throws — it read
2107-
// no value, and a node whose flight is up is the hold's work, not a
2108-
// verdict reader (D-25, #3884). Stamped, the pass's next run — the
2109-
// hold's re-run at the landing of a memo whose plain mount read
2110-
// held its reader (D-2, D-27) — was served the screen beside the
2111-
// answer its reader waited for (F-2, D-22). A verdict reader keeps
2112-
// the posture it is served the screen with (`observeFlight`).
2113-
// (A verdict memo exists only with the verdict engine installed.)
2106+
// the hold's own work and not a verdict reader already (#4504):
2107+
// such a read throws — it read no value, and a node whose flight is
2108+
// up is the hold's work, not a verdict reader (D-25, #3884). The
2109+
// hold's own work is a pass born in its world (uninitialized, D-27)
2110+
// or one over a pass of its own still staged for the commit.
2111+
// Stamped, its next run — the hold's re-run at the landing of a
2112+
// memo whose plain mount read held its reader (D-2, D-27) — was
2113+
// served the screen beside the answer its reader waited for (F-2,
2114+
// D-22). A memo with a committed value and none staged is no hold's
2115+
// work, and its posture lasts until a pass completes having read no
2116+
// verdict reader (D-25, ruled 2026-10-28) — a pass that threw on a
2117+
// pending read did not complete. Unstamped, `latest(m2)` over a
2118+
// verdict memo showed its re-run's staging ahead of the lane that
2119+
// staging lands with (#4408). A
2120+
// verdict reader keeps the posture it is served the screen with
2121+
// (`observeFlight`). (A verdict memo exists only with the verdict
2122+
// engine installed.)
21142123
if (observeFlightHook && !(c as any)._type)
21152124
(c as Computed<any>)._flags |=
2116-
owner._config & CONFIG_VERDICT & (owner._statusFlags & STATUS_PENDING ? c._config : -1);
2125+
owner._config &
2126+
CONFIG_VERDICT &
2127+
(owner._statusFlags & STATUS_PENDING &&
2128+
(c._config & CONFIG_STAGED || (c as Computed<any>)._statusFlags & STATUS_UNINITIALIZED)
2129+
? c._config
2130+
: -1);
21172131
}
21182132
}
21192133
if (__TEST__)

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
import {
3333
CONFIG_AUTHORITATIVE,
3434
CONFIG_CHILDREN_FORBIDDEN,
35+
CONFIG_FRAME,
3536
CONFIG_GUESS,
3637
CONFIG_HELD,
3738
CONFIG_HELD_FRAME,
3839
CONFIG_INPUTS_PUBLISHED,
40+
CONFIG_LAGS,
3941
CONFIG_OVERRIDE,
4042
CONFIG_SLOT_NODE,
4143
CONFIG_STAGED,
@@ -290,11 +292,27 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
290292
// on any later run (CONFIG_HELD_FRAME, `bornInto`): born in the hold's
291293
// world, it is the hold's own work and its run is the frame's, at the
292294
// landing (D-25, D-27) — as `route` keeps it for the inline `latest()`.
295+
// Nor by a pass that re-entered the hold holding its node at its head
296+
// (core.ts `recompute`: held, with no verdict posture — an async memo's
297+
// was dropped there — not a frame, not lagging, not a lane's node), when
298+
// `l` is another hold's verdict lane: re-run by the write its hold
299+
// holds, the pass is that hold's work and reads plainly in either read
300+
// order (D-25), as it does reading its hold's staging before `l`'s
301+
// value. Moved into `l`, it read its own hold's landing as the screen
302+
// (D-26) and asked a question already asked (#4399: `m1:15` again, over
303+
// `m0b`'s committed value beside the landing of its next question). Its
304+
// own hold's verdict lane is its display-ahead read: it enters that one
305+
// (D-25, #4050).
306+
let hold: Transaction;
293307
if (
294308
!(
295309
verdict &&
296310
(creatorReads(c, (c as any)._type || f) ||
297-
(c._config & CONFIG_HELD_FRAME && bornInto(c, resolveTx(l._parent!))))
311+
((hold = resolveTx(l._parent!)),
312+
(c._config &
313+
(CONFIG_HELD | CONFIG_VERDICT | CONFIG_FRAME | CONFIG_LAGS | CONFIG_OVERRIDE)) ===
314+
CONFIG_HELD && txOf(c) !== hold) ||
315+
(c._config & CONFIG_HELD_FRAME && bornInto(c, hold!)))
298316
)
299317
) {
300318
setPassLane(l);

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,19 +630,32 @@ function verdictValue(el: Signal<any> | Computed<any>, c: Computed<any> | null):
630630
* no value, so its re-run re-asked the question it was answering. Unless
631631
* its own flight is up outside a lane on a new question of the source's:
632632
* its re-run supersedes a flight asked of a value the source has moved past
633-
* (re-asked by a `refresh()`, the source's question is the same one). */
633+
* (re-asked by a `refresh()`, the source's question is the same one).
634+
*
635+
* Waiting, it is the hold's work until a pass of it reads a verdict again,
636+
* so the verdict posture drops here, at the wait (the pass's own reads
637+
* stamp it again, `read`). Kept, the source's next pending — its verdict
638+
* lane's re-derive at the park (#4393) — re-derived the waiting memo as a
639+
* verdict reader into that lane while the hold's flight it waits on was
640+
* still up, and the pass the landing runs, its hold re-running it, read as
641+
* a verdict reader: the head that drops the posture for such a pass sees
642+
* neither pending (the landing settles the node first) nor held (a lane's
643+
* node). #4408: `m1` entered the s lane early, the lane was unshown when
644+
* `m1:22` landed, nothing held the frame `m0b:1100` landed into, and the
645+
* lane's reader `latest(m2)` showed `c1101` while `m1:1122` was in flight. */
634646
function holdWork(n: Computed<any>, source: Computed<any>): unknown {
635647
// CONFIG_ASYNC records an async memo with no window of its own: its last
636648
// answering pass registered a flight (`handleAsync`) and called neither
637649
// `latest` nor `isPending`. A window (`markVerdictReader`), a sync answer or
638650
// an error clears it; a pass left pending keeps the last answer's.
639-
const own = n._config & CONFIG_ASYNC;
640-
return (
641-
own &&
651+
// Waiting drops the posture; the result stays truthy (CONFIG_ASYNC is kept).
652+
if (
653+
n._config & CONFIG_ASYNC &&
642654
(!(n._statusFlags & STATUS_PENDING) ||
643655
n._x!._transaction?._lane ||
644656
source._flags & REACTIVE_REASK)
645-
);
657+
)
658+
return (n._config &= ~CONFIG_VERDICT);
646659
}
647660

648661
// Installed at module evaluation — present exactly when something imports

‎packages/signals/src/store/store.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
CONFIG_MANUAL_WRITE,
3838
CONFIG_OVERRIDE,
3939
CONFIG_PROMOTED,
40+
CONFIG_STAGED_ERROR,
4041
CONFIG_VERDICT,
4142
EFFECT_RENDER,
4243
NOT_PENDING,
@@ -1855,7 +1856,8 @@ function pullFamily(target: StoreTarget): void {
18551856
// reader of a memo would — linked, so it re-runs at the landing (the
18561857
// next settled pass pulls without linking and the stale link trims), a
18571858
// verdict reader registered, a tracked pass suspended.
1858-
if (fw._statusFlags & (STATUS_PENDING | STATUS_ERROR)) {
1859+
// A staged error (D-41) throws at the pull, before any leaf would link the reader.
1860+
if (fw._statusFlags & (STATUS_PENDING | STATUS_ERROR) || fw._config & CONFIG_STAGED_ERROR) {
18591861
// A render effect outside the flight's own flush is the frame, not a
18601862
// derivation: it keeps what it shows and learns of the landing from the
18611863
// leaves the landing changes (unchanged leaves say nothing — it is not a
@@ -1869,7 +1871,7 @@ function pullFamily(target: StoreTarget): void {
18691871
if (
18701872
c !== null &&
18711873
c._type === EFFECT_RENDER &&
1872-
!(fw._statusFlags & STATUS_ERROR) &&
1874+
fw._statusFlags & STATUS_PENDING &&
18731875
fw._config & CONFIG_HELD &&
18741876
flushTransaction !== txOf(fw) &&
18751877
!linkedTo(c, fw)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { expect, it } from "vitest";
2+
import {
3+
createErrorBoundary,
4+
createLoadingBoundary,
5+
createMemo,
6+
createProjection,
7+
createRenderEffect,
8+
createRoot,
9+
createSignal,
10+
flush,
11+
mapArray,
12+
untrack
13+
} from "../src/index.js";
14+
15+
const tick = async () => {
16+
for (let i = 0; i < 4; i++) {
17+
await new Promise(r => setTimeout(r, 0));
18+
flush();
19+
}
20+
};
21+
22+
type Row = { id: number; name: string };
23+
24+
for (const keyed of [true, false])
25+
it(`an answer replaces the error a boundary was born with (projection: ${keyed}) (#4517)`, async () => {
26+
const asks: { key: string; res: (v: Row[]) => void }[] = [];
27+
const ask = (key: string) => new Promise<Row[]>(res => asks.push({ key, res }));
28+
const land = async (key: string, v: Row[]) => {
29+
for (const a of asks.filter(a => a.key === key)) {
30+
asks.splice(asks.indexOf(a), 1);
31+
a.res(v);
32+
}
33+
await tick();
34+
};
35+
const [q, setQ] = createSignal("");
36+
let screen: unknown;
37+
const dispose = createRoot(d => {
38+
const src = createMemo(() => {
39+
const s = q();
40+
if (s === "") return [] as Row[];
41+
if (s.length < 2) throw new Error("too short");
42+
return ask(`search:${s}`);
43+
});
44+
const results: () => Row[] = keyed
45+
? (() => {
46+
const p = createProjection(() => src(), [] as Row[], { key: "id" });
47+
return () => p;
48+
})()
49+
: src;
50+
const show = createMemo(() => q() !== "");
51+
const out = createMemo(() => {
52+
if (!show()) return undefined;
53+
return untrack(() =>
54+
createErrorBoundary(
55+
() =>
56+
createLoadingBoundary(
57+
() => mapArray(results, r => r.name),
58+
() => "loading"
59+
),
60+
e => `E:${(e() as Error).message}`
61+
)
62+
);
63+
});
64+
const resolve = (v: unknown): unknown =>
65+
typeof v === "function" ? resolve(v()) : Array.isArray(v) ? v.join("") : v;
66+
createRenderEffect(
67+
() => resolve(out()),
68+
v => void (screen = v)
69+
);
70+
return d;
71+
});
72+
await tick();
73+
expect(screen).toBe(undefined);
74+
setQ("a");
75+
await tick();
76+
expect(screen).toBe("E:too short");
77+
setQ("ap");
78+
await tick();
79+
expect(screen).toBe("E:too short");
80+
await land("search:ap", [
81+
{ id: 1, name: "apple" },
82+
{ id: 2, name: "apricot" }
83+
]);
84+
expect(screen).toBe("appleapricot");
85+
dispose();
86+
});

‎packages/signals/tests/latest-first-one-pass-4402.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// Pins for what #4393 (R5, D-22) fixed beyond #4365, and one row it leaves
2-
// for the reader-seat carve.
1+
// Pins for what #4393 (R5, D-22) fixed beyond #4365, and #4399.
32
//
43
// - #4402: a pass that reads `latest(s)` before `s()` computes once per
54
// plain write, as `[s(), latest(s)]` does (D-22: one pass; it re-derives
65
// only if the flush parks).
76
// - #4398: `[isPending(m1), m1()]` in one effect, split across two, or
87
// `m1()` alone show the same values when the write changes during the hold
98
// (D-26, F-6: a grouped read holds as a lone read; #4284).
10-
// - #4399 (it.fails, carve row): two actions, each holding a verdict
11-
// memo's write, ask `m1:15` twice: once in A's verdict lane, once in B's
12-
// transaction over the same inputs (F-9).
9+
// - #4399: two actions, each holding a verdict memo's write, ask `m1:15`
10+
// once: in A's verdict lane. `m1`'s pass over `m0b`'s landing is the
11+
// hold's work (D-25: re-run by the write its hold holds, it reads plainly
12+
// in either read order) and stays out of A's lane; moved into it, it read
13+
// the landing as the screen and asked `m1:15` again (F-9).
1314
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1415
import {
1516
action,
@@ -129,14 +130,13 @@ describe("#4398: grouping isPending(m1) with m1() shows the same values", () =>
129130
});
130131

131132
describe("#4399: two actions, each holding a verdict memo's write", () => {
132-
// F-9: a re-ask of the same question is no new question. A row for the
133-
// reader-seat carve: telling B's pass apart from A's lane pass over the
134-
// same inputs needs a per-pass check.
133+
// F-9: a re-ask of the same question is no new question. D-25: `m1`'s
134+
// pass over `m0b`'s landing is its hold's work, not A's verdict lane's
135+
// (lanes.ts `holdsPass`).
135136
const once = async (reader: Reader) => {
136137
const { asks, values } = await run(reader, "two-actions");
137138
expect(new Set(asks).size, asks.join(" ")).toBe(asks.length);
138139
expect(values.at(-1)).toBe("26");
139140
};
140-
it("each question asked once (pair)", () => once("pair"));
141-
it.fails.each(["split", "value"] as const)("each question asked once (%s)", once);
141+
it.each(["pair", "split", "value"] as const)("each question asked once (%s)", once);
142142
});

‎packages/signals/tests/latest-two-readers-one-ask-4393.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ describe("#4393: two latest() readers under one async memo, t written during the
130130
};
131131
it("m1's lane pass is not re-derived over a staging that lands with it (value)", () =>
132132
notReDerived("value"));
133-
// F-6 (amended 2026-10-28: the parent waits for the lane's flights) and
134-
// D-26. Fails with #4397 merged (#4393 alone passed): #4397 makes `m1` a
135-
// verdict reader between its flights (D-25), so m0's lane pass re-derives
136-
// it into the s lane early; the lane is unshown when `m1:22` lands, nothing
137-
// holds the t transaction, and `c1101` shows while `m1:1122` is in flight.
138-
// A row for the reader-seat carve: telling "its hold re-runs it" (D-25)
139-
// apart at that landing needs a per-pass check.
140-
it.fails("m1's lane pass is not re-derived over a staging that lands with it (beside)", () =>
141-
notReDerived("beside")
142-
);
133+
// #4408 — F-6 (amended 2026-10-28: the parent waits for the lane's
134+
// flights) and D-26: the lane's readers show its answer together, so
135+
// `c1101` never shows before `v1122`. `m1` waits on `m0`'s flight as the
136+
// hold's work (D-25, verdict.ts `holdWork`): it is not re-derived into the
137+
// s lane early, the lane shows, and `m1:22`'s landing holds the frame
138+
// `m0b:1100` lands into. Re-derived early (#4397's verdict reader between
139+
// its flights), the lane was unshown when `m1:22` landed, nothing held
140+
// that frame, and `c1101` showed while `m1:1122` was in flight.
141+
it("m1's lane pass is not re-derived over a staging that lands with it (beside, #4408)", () =>
142+
notReDerived("beside"));
143143

144144
// Its lane's own render effect shows m1 (pair): the staging's transaction
145145
// lands at the very seam, so the pass read the screen (one run).
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* @jsxImportSource @solidjs/web
3+
* @vitest-environment jsdom
4+
*/
5+
import { expect, test } from "vitest";
6+
import { render } from "../src/index.js";
7+
import {
8+
createMemo,
9+
createProjection,
10+
createSignal,
11+
Errored,
12+
flush,
13+
For,
14+
Loading,
15+
Show
16+
} from "solid-js";
17+
18+
type Row = { id: number; name: string };
19+
20+
const tick = async () => {
21+
for (let i = 0; i < 4; i++) {
22+
await new Promise(r => setTimeout(r, 0));
23+
flush();
24+
}
25+
};
26+
27+
test.each([true, false])(
28+
"an answer replaces the error a boundary was born with (projection: %s)",
29+
async projection => {
30+
const asks: { key: string; res: (v: Row[]) => void }[] = [];
31+
const ask = (key: string) => new Promise<Row[]>(res => asks.push({ key, res }));
32+
const land = async (key: string, v: Row[]) => {
33+
for (const a of asks.filter(a => a.key === key)) {
34+
asks.splice(asks.indexOf(a), 1);
35+
a.res(v);
36+
}
37+
await tick();
38+
};
39+
const container = document.createElement("div");
40+
const [q, setQ] = createSignal("");
41+
const dispose = render(() => {
42+
const src = createMemo(() => {
43+
const s = q();
44+
if (s === "") return [] as Row[];
45+
if (s.length < 2) throw new Error("too short");
46+
return ask(`search:${s}`);
47+
});
48+
const results: () => Row[] = projection
49+
? (() => {
50+
const p = createProjection(() => src(), [] as Row[], { key: "id" });
51+
return () => p;
52+
})()
53+
: src;
54+
return (
55+
<Show when={q() !== ""}>
56+
<Errored fallback={(e: () => any) => <p>{e().message}</p>}>
57+
<Loading fallback={<p>loading</p>}>
58+
<For each={results()}>{r => <i>{r.name}</i>}</For>
59+
</Loading>
60+
</Errored>
61+
</Show>
62+
);
63+
}, container);
64+
await tick();
65+
expect(container.textContent).toBe("");
66+
setQ("a");
67+
await tick();
68+
expect(container.textContent).toBe("too short");
69+
setQ("ap");
70+
await tick();
71+
expect(container.textContent).toBe("too short");
72+
await land("search:ap", [
73+
{ id: 1, name: "apple" },
74+
{ id: 2, name: "apricot" }
75+
]);
76+
expect(container.textContent).toBe("appleapricot");
77+
dispose();
78+
}
79+
);

0 commit comments

Comments
 (0)