Skip to content

Commit 544ad8a

Browse files
committed
Merge next into #4385 and re-record its size ledgers over next @ b68942c
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
2 parents 7452e7b + b68942c commit 544ad8a

13 files changed

Lines changed: 685 additions & 26 deletions
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+
An uninitialized async memo whose re-run throws from a dependency now reaches the wrapping `<Errored>` (#4364). The dependency's error was staged for the commit (D-41), but a reader threw it at once: a render effect reading a memo born staged, or the memo itself through `latest()`. The error reached the boundary naming that source, and the boundary's next pass took the source as settled because its error was only staged. It dropped the source and showed the content, so `Loading` revealed an empty hole that never recovered. An error staged on its source now keeps the boundary waiting until the commit publishes it.
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+
`isPending(s)` read through a memo (`<Show when={isPending(s)}>`, a compiled ternary's condition) no longer stays `true` after an action completes when `s` is also written outside the action (#4367). The outside write that matches the action's value ends the verdict, and the memo's pass leaves the verdict lane on a value equal to its committed one, so the equality gate notified nobody; the lane seam woke the reader that still showed the lane's `true` only when the lane's frame was not held, and the action held it. A pass outside any transaction's flush is the screen's: its readers now re-derive at the seam, as the inline `isPending(s)` does.
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 `<Loading on>` boundary no longer shows its fallback when a held `on` change commits under an action's own `refresh()` (#4379). When an `on` change is held with an action (an input changed under its optimistic guess, #4336) and the content's new answer lands inside that hold a flush after the change, the boundary now folds the staged fallback back, as it already did when the content was ready at the change. The action's commit shows the content, and the quiet `refresh()` that follows keeps it on screen until it answers.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Whether a fallback is seen depends on whether the boundary is on screen. A fresh
120120

121121
A flight whose only observers are render effects behind a fallback holds no change — a memo under the boundary that no render effect reads was never an observer at all, and one rendered by an effect outside the boundary is that effect's read (F-3). In both orders: a render effect created under a fallback never counts, and a reader that counted while the boundary showed content stops counting the moment `on` sends it back to the fallback. Writes the hold kept for those readers alone commit at once (`Boundary: Loading... | Sum: 2` publishes as one frame); a reader outside the boundary still holds (`Sum` waits until `details` lands). The wait does not vanish; it moves onto the boundary: after the reset the fallback stays until every reader under it has settled — including readers whose flights started before the reset — then one coherent reveal.
122122

123-
**Collapses:** [A33](./SPEC-ASYNC-SEMANTICS.md#a33-a-fallback-caught-flight-holds-no-transaction-a-loading-reset-moves-the-hold-onto-the-boundary) (#3375, #3459), §23.1 item 1, recovery 2.2. **Status:** standing. The nested form — an outer `on`-reset boundary not waiting for a flight its nested `on`-reset boundary catches — is built (U-4, 2026-10-13: a reader a nested collecting boundary holds is that boundary's alone; `tests/fuzz-findings-l2.test.ts`, fuzzer finding F1). The re-arm over a hold is built (U-9, 2026-10-14): content an earlier hold staged under the boundary, or that reads a hold after the re-arm, is the boundary's — the fallback shows now and the content reveals at that hold's commit, which does not wait for it; no redraw loop (`tests/loading-fallback-in-flush-3540.test.ts`, the re-armed shapes; `tests/loading-on-frame-following-3540.test.ts` §3b, §3c).
123+
**Collapses:** [A33](./SPEC-ASYNC-SEMANTICS.md#a33-a-fallback-caught-flight-holds-no-transaction-a-loading-reset-moves-the-hold-onto-the-boundary) (#3375, #3459), §23.1 item 1, recovery 2.2. **Status:** standing. The nested form — an outer `on`-reset boundary not waiting for a flight its nested `on`-reset boundary catches — is built (U-4, 2026-10-13: a reader a nested collecting boundary holds is that boundary's alone; `tests/fuzz-findings-l2.test.ts`, fuzzer finding F1). The re-arm over a hold is built (U-9, 2026-10-14): content an earlier hold staged under the boundary, or that reads a hold after the re-arm, is the boundary's — the fallback shows now and the content reveals at that hold's commit, which does not wait for it; no redraw loop (`tests/loading-fallback-in-flush-3540.test.ts`, the re-armed shapes; `tests/loading-on-frame-following-3540.test.ts` §3b, §3c). A fallback staged into the hold its readers land in folds back at any seam, not only the re-arm's own: readers still pending at the re-arm land into that hold a flush later, and the content is ready when it commits (#4379, `tests/loading-on-held-filter-refresh-4379.test.ts`).
124124

125125
### D-15. `on` is a dependency list; the swap lands with the frame of the change that caused it
126126

‎packages/signals/src/boundaries.ts‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import {
4343
CAUGHT_REARMED,
4444
CONFIG_REDERIVE,
45+
CONFIG_STAGED_ERROR,
4546
CONFIG_FRAME,
4647
CONFIG_HELD,
4748
CONFIG_OVERRIDE,
@@ -232,16 +233,20 @@ function catchStatus(
232233
): boolean | typeof CAUGHT_REARMED {
233234
if (flags === 0) {
234235
// A status cleared. Judged by the node's status now, against each
235-
// boundary's own rule (`unsettled`) — the error path clears pending
236+
// boundary's own rule (`prune`'s mask) — the error path clears pending
236237
// first and the node is still errored then. The last reader a fallback
237238
// waited on settling re-derives the output now, in the same heap (a
238239
// held reader's landing has joined its transaction, so the content
239240
// lands with its run, not a round after). Others still waiting: nothing
240-
// on screen changes, the fallback stays as it is.
241+
// on screen changes, the fallback stays as it is. `node` here is an
242+
// effect reporting its own status. An error boundary records an effect
243+
// only while it is errored, and a staged error keeps STATUS_ERROR on a
244+
// node that had it (`stageError`), so `prune`'s CONFIG_STAGED_ERROR case
245+
// cannot reach this path (#4364).
241246
if (collecting.size !== 0)
242247
for (let b: Boundary | null | undefined = boundaryOf(node); b; b = b._parent)
243248
if (
244-
!(node._statusFlags & unsettled(b)) &&
249+
!(node._statusFlags & (b._type | STATUS_PENDING)) &&
245250
b._readers.delete(node) &&
246251
b._readers.size === 0
247252
) {
@@ -316,15 +321,18 @@ function release(b: Boundary): void {
316321
* that landed but is held (its value staged in a transaction) is not: the
317322
* content reveals at the commit, with its run. The tree is: the output reads
318323
* it and enters the transaction itself (its committed value shows until the
319-
* landing). */
320-
const unsettled = (b: Boundary): number =>
321-
b._type === STATUS_ERROR ? STATUS_ERROR | STATUS_PENDING : STATUS_PENDING;
322-
324+
* landing). The statuses that keep a reader: pending — and its error, for an
325+
* error boundary (`_type` is the status it catches). */
323326
export function prune(b: Boundary, pass: boolean): number {
324-
const mask = unsettled(b);
327+
const mask = b._type | STATUS_PENDING;
325328
for (const r of b._readers) {
326-
if (r._flags & REACTIVE_DISPOSED) b._readers.delete(r);
327-
else if (!(r._statusFlags & mask)) {
329+
if (!(r._flags & REACTIVE_DISPOSED)) {
330+
// An error staged on its source (D-41, `stageError`) is not settled:
331+
// it publishes with the commit. A reader that threw it now (a lane
332+
// pass, a reader of a node born staged) reached the boundary first
333+
// (#4364).
334+
if (r._statusFlags & mask || (mask & STATUS_ERROR && r._config & CONFIG_STAGED_ERROR))
335+
continue;
328336
if (
329337
(r !== b._tree || b._armed) &&
330338
(r._config & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD
@@ -339,8 +347,8 @@ export function prune(b: Boundary, pass: boolean): number {
339347
if (!pass || !b._initialized) continue;
340348
joinFuture(txOf(r));
341349
}
342-
b._readers.delete(r);
343350
}
351+
b._readers.delete(r);
344352
}
345353
return b._readers.size;
346354
}
@@ -374,8 +382,12 @@ function boundarySeam(): void {
374382
if (flags & REACTIVE_ZOMBIE) continue;
375383
prune(b, false);
376384
const o = b._output!;
385+
// A fallback staged into the very hold its readers landed in folds back
386+
// (D-16, U-9): the content is ready when that hold commits (D-15). Not
387+
// only at the re-arm's own seam: readers pending then land, held, a
388+
// flush later (#4379 — the staged fallback otherwise commits with the
389+
// hold, and a quiet refresh then caught keeps it up, F-9).
377390
if (
378-
b._armed &&
379391
!b._initialized &&
380392
o._config & CONFIG_HELD &&
381393
[...b._readers].every(

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,16 @@ export function laneStage(
357357
const x = el._x;
358358
if (x !== null) {
359359
const tx = x._transaction;
360-
// Cleared before equality, so a return to the committed value notifies
361-
// nobody. The seam wakes it unless the frame is still held (#3892).
362-
if (tx?._shown && !blocked(resolveTx(tx!._parent!))) el._flags |= LEFT_SHOWN;
363-
if (tx?._lane) x._transaction = null;
360+
if (tx?._lane) {
361+
// Cleared before equality, so a return to the committed value
362+
// notifies nobody. The seam wakes it (#3892) — not while a
363+
// transaction's flush runs the pass and the lane's frame is still
364+
// held, but always for a pass outside any transaction's flush: its
365+
// value is the screen's now (#4367). (Only a lane is ever `_shown`.)
366+
if (tx._shown && (!flushTransaction || !blocked(resolveTx(tx._parent!))))
367+
el._flags |= LEFT_SHOWN;
368+
x._transaction = null;
369+
}
364370
x._lane = NOT_PENDING;
365371
}
366372
el._config &= ~(CONFIG_OVERRIDE | CONFIG_HELD | CONFIG_HELD_FRAME);
@@ -382,12 +388,12 @@ export function laneStage(
382388
// question, which the guess (over the old one) does not answer — the
383389
// lane waits for its own answer (F-1, F-6, #4336). (A guess of the
384390
// lane's own action, D-33's entangled slot, still stands in.)
385-
const g = el._x!._transaction;
391+
// (Read behind `guessed`: a bundle without optimism drops the reads.)
386392
if (
387393
guessed &&
388394
el._config & CONFIG_GUESS &&
389-
g?._lane &&
390-
resolveTx(g._parent!) !== resolveTx(l._parent!)
395+
el._x!._transaction?._lane &&
396+
resolveTx(el._x!._transaction!._parent!) !== resolveTx(l._parent!)
391397
)
392398
take(el, l);
393399
else if (!errored) el._config &= ~CONFIG_GUESS;
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// #4367: a verdict memo — `<Show when={isPending(s)}>`'s condition — reads
2+
// `true` from the verdict lane while an action holds its write to `s`. A
3+
// write outside the action that matches the action's value ends the verdict
4+
// (nothing differs from the held write), and the memo's mainline pass leaves
5+
// the lane on `false`, equal to its committed value: the equality gate
6+
// notifies nobody, and the lane seam only woke a reader that had seen the
7+
// lane's slot when the lane's frame was not held. The action is still open,
8+
// so the reader kept `pending` for good — beside the inline form, which reads
9+
// `false` at that flush (D-17: a memo between `isPending` and its reader
10+
// behaves as the direct read does). A pass outside any transaction's flush
11+
// publishes to the screen: its readers re-derive at the seam whatever holds
12+
// the lane's frame.
13+
import { describe, expect, it } from "vitest";
14+
import {
15+
action,
16+
createMemo,
17+
createRenderEffect,
18+
createRoot,
19+
createSignal,
20+
flush,
21+
isPending
22+
} from "../src/index.js";
23+
24+
const tick = async () => {
25+
for (let i = 0; i < 8; i++) await Promise.resolve();
26+
flush();
27+
};
28+
29+
describe("#4367 isPending(s) after an action, with s also written outside it", () => {
30+
for (const memo of [false, true])
31+
for (const value of [false, true])
32+
it(`${memo ? "memo" : "inline"} verdict${value ? " beside s()" : ""}`, async () => {
33+
const [s, set] = createSignal(2);
34+
let release!: () => void;
35+
const act = action(function* (v: number) {
36+
set(v);
37+
yield new Promise<void>(r => (release = r));
38+
});
39+
const frames: string[] = [];
40+
const dispose = createRoot(dispose => {
41+
const pending = memo ? createMemo(() => isPending(s)) : () => isPending(s);
42+
createRenderEffect(
43+
() => (pending() ? "pending" : "F") + (value ? s() : ""),
44+
v => {
45+
frames.push(v);
46+
}
47+
);
48+
return dispose;
49+
});
50+
const v = (n: number) => (value ? String(n) : "");
51+
flush();
52+
act(3);
53+
set(2);
54+
await tick();
55+
expect(frames).toEqual([`F${v(2)}`, `pending${v(2)}`]);
56+
set(3);
57+
flush();
58+
// Nothing differs from the action's write: not pending, in either form.
59+
expect(frames.at(-1)).toBe(`F${v(3)}`);
60+
release();
61+
await tick();
62+
expect(s()).toBe(3);
63+
expect(isPending(s)).toBe(false);
64+
expect(frames.at(-1)).toBe(`F${v(3)}`);
65+
dispose();
66+
});
67+
68+
it("the generated variant: s=0, A(s=2), s=0, tick, s=2", async () => {
69+
const [s, set] = createSignal(0);
70+
let release!: () => void;
71+
const act = action(function* (v: number) {
72+
set(v);
73+
yield new Promise<void>(r => (release = r));
74+
});
75+
const frames: string[] = [];
76+
const dispose = createRoot(dispose => {
77+
const pending = createMemo(() => isPending(s));
78+
createRenderEffect(
79+
() => (pending() ? "pending" : "F"),
80+
v => {
81+
frames.push(v);
82+
}
83+
);
84+
return dispose;
85+
});
86+
flush();
87+
act(2);
88+
set(0);
89+
await tick();
90+
set(2);
91+
flush();
92+
release();
93+
await tick();
94+
expect(isPending(s)).toBe(false);
95+
expect(frames).toEqual(["F", "pending", "F"]);
96+
dispose();
97+
});
98+
});
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// #4364 (D-41, F-12): an error staged on its source is not settled. A memo's
2+
// pass throws in a flush that carries a write, so its error is staged
3+
// (`stageError`) and publishes with the commit. A reader that throws the same
4+
// error during the pass publishes it at once: an uninitialized async memo's
5+
// render effect reading the memo's staged error (it read a node born staged),
6+
// or the memo itself reading it through `latest()` (a verdict lane pass). The
7+
// error reaches `<Errored>` naming the source, whose own error is still only
8+
// staged. The boundary's output pass took that source as settled, dropped it,
9+
// and showed the content: an empty hole under a revealed `<Loading>`, and the
10+
// commit's publish found every reader already holding that error, so nothing
11+
// told the boundary again.
12+
import { expect, it } from "vitest";
13+
import {
14+
createErrorBoundary,
15+
createLoadingBoundary,
16+
createMemo,
17+
createRenderEffect,
18+
createRoot,
19+
createSignal,
20+
flush,
21+
latest,
22+
untrack
23+
} from "../src/index.js";
24+
25+
const tick = async () => {
26+
for (let i = 0; i < 8; i++) await Promise.resolve();
27+
flush();
28+
};
29+
30+
it.each(["m0() + s()", "latest(m0)", "m0()"])(
31+
"an uninitialized async memo reading %s reaches <Errored> when its dependency throws",
32+
async shape => {
33+
const [s, set] = createSignal(0);
34+
let release!: (v: unknown) => void;
35+
const gate = new Promise(r => (release = r));
36+
let out = "";
37+
const dispose = createRoot(dispose => {
38+
const m0 = createMemo(() => {
39+
if (s() === 2) throw new Error("boom");
40+
return s();
41+
});
42+
const m1 = createMemo(() => {
43+
const v = shape === "latest(m0)" ? latest(m0) : shape === "m0()" ? m0() : m0() + s();
44+
return gate.then(() => v);
45+
});
46+
// `<Errored><Loading><span>{m1()}</span></Loading></Errored>`
47+
const view = createErrorBoundary(
48+
() =>
49+
createLoadingBoundary(
50+
() =>
51+
untrack(() => {
52+
createRenderEffect(
53+
() => m1(),
54+
() => {}
55+
);
56+
return "content";
57+
}),
58+
() => "[L]"
59+
),
60+
(e: () => any) => `[E ${e()?.message}]`
61+
);
62+
createRenderEffect(
63+
() => {
64+
const v = view();
65+
return typeof v === "function" ? (v as () => unknown)() : v;
66+
},
67+
v => void (out = String(v))
68+
);
69+
return dispose;
70+
});
71+
flush();
72+
expect(out).toBe("[L]");
73+
set(2);
74+
flush();
75+
expect(out).toBe("[E boom]");
76+
release(1);
77+
await tick();
78+
expect(out).toBe("[E boom]");
79+
dispose();
80+
}
81+
);

0 commit comments

Comments
 (0)