Skip to content

Commit a56b10b

Browse files
ryansolidclaude
andauthored
fix(signals): <Errored> recovery waits on a reader still pending behind its fallback (#4592) (#4608)
* fix(signals): <Errored> recovery waits on a reader still pending behind its fallback (#4592) While an error boundary shows its fallback, a frame reader under it that goes pending passes the boundary by (A6) and, hidden, holds nothing — so nothing waited on it. When the source that threw answered, the boundary revealed the content with that reader's stale value beside the new input (`s=1a=10b=21`). `catchStatus` now records such a pending reader on an error boundary showing its fallback (as `caught` already does for a pending caught by a hidden inner loading fallback): the error stays the display until every reader answers (D-39, F-1). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * docs(signals): regenerate RULES-INDEX for #4592's citations Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE --------- Co-authored-by: Claude <[email protected]>
1 parent 2abd9a2 commit a56b10b

5 files changed

Lines changed: 168 additions & 2 deletions

File tree

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+
`<Errored>` no longer recovers beside a memo that is still answering an older input (#4592). While the error fallback shows, a reader behind it that goes pending — which passes the error boundary by (A6) and, hidden, holds nothing — is now also waited on by the boundary, as a pending under a hidden loading fallback already was. When the source that threw answers but another reader in the content is still asking for the new input, the error stays the display until that reader answers too, so the content reveals as one whole frame instead of showing the pending memo's stale value beside the new input (D-39, F-1).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
5050
| A3 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:337` | async.ts×1 core.ts×2 | derived-write-then-derivation-3733.test.ts×5 equals-comparator-errors.test.ts×1 | [ruled] Comparator throws are compute-phase errors — Errors thrown by a user `equals` comparator behave exactly like compute-phase errors (boundary-containable; loud halt without a boundary). |
5151
| A4 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:345` | — | derived-write-then-derivation-3733.test.ts×1 equals-comparator-errors.test.ts×1 | [ruled] A custom `equals` never sees `undefined` prev on first commit — A custom `equals` is never invoked with `undefined` previous value on a node's first commit. |
5252
| A5 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:353` | — | derived-write-then-derivation-3733.test.ts×1 errorHalt.test.ts×1 | [ruled] An error escaping every boundary halts the system — An error escaping every boundary permanently halts the system with `REACTIVITY_HALTED`; later writes log "Update ignored". |
53-
| A6 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:361` | boundaries.ts×2 | derived-write-then-derivation-3733.test.ts×1 enforceLoadingBoundary.test.ts×1 | [ruled] `ASYNC_OUTSIDE_LOADING_BOUNDARY` is warn-only — `ASYNC_OUTSIDE_LOADING_BOUNDARY` is a warn-only diagnostic; an `Errored` above must not swallow it and must not show its fallback for a pending. |
53+
| A6 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:361` | boundaries.ts×3 | derived-write-then-derivation-3733.test.ts×1 enforceLoadingBoundary.test.ts×1 | [ruled] `ASYNC_OUTSIDE_LOADING_BOUNDARY` is warn-only — `ASYNC_OUTSIDE_LOADING_BOUNDARY` is a warn-only diagnostic; an `Errored` above must not swallow it and must not show its fallback for a pending. |
5454
| A7 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:167` | seat.ts×1 truth.ts×1 verdict.ts×1 | fuzz-findings-l2.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×2 spec-async-semantics.test.ts×2 visibility-oracle-store.states.ts×1 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled, amended in place] Resolved async never reads `[false, undefined]` — After an async memo resolves, `[isPending(x), latest(x)]` is `[false, resolvedValue]` — never `[false, undefined]`. **Amende… |
5555
| A8 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:175` | — | create-deferred-3710.test.ts×1 createMemo.test.ts×1 visibility-oracle-store.states.ts×1 visibility-oracle.states.ts×2 | [ruled, amended in place 2026-07-07] `isPending(() => latest(x))` follows `x`'s own async only — verdicts are per-channel — (**re-ruled 2026-07-07c** — was "tracks the transition the same as `isPendin… |
5656
| A9 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:183` | async.ts×1 projection.ts×1 target.ts×1 | spec-async-semantics.test.ts×3 visibility-oracle-store.states.ts×4 visibility-oracle-store.test.ts×1 | [ruled, amended in place 2026-07-07] Store leaves behind a firewall report the firewall's new-question refetch — `isPending` on a store leaf behind a firewall reports the firewall's refetch like any a… |

‎packages/signals/src/boundaries.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,13 @@ function catchStatus(
274274
return false;
275275
}
276276
for (let b: Boundary | null | undefined = boundaryOf(node); b; b = b._parent) {
277-
if (!(b._type & flags)) continue;
277+
if (!(b._type & flags)) {
278+
// A pending passing an error fallback by (A6) is still a reader the
279+
// content needs: the error stays the display until it answers too —
280+
// revealed beside its stale value, the frame tears (D-39, F-1, #4592).
281+
if (b._fallback && b._type > flags) record(b, node);
282+
continue;
283+
}
278284
if (isCollecting(b)) {
279285
caught(b, node, error);
280286
return b._armed ? CAUGHT_REARMED : true;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { expect, it } from "vitest";
2+
import {
3+
createErrorBoundary,
4+
createLoadingBoundary,
5+
createMemo,
6+
createRenderEffect,
7+
createRoot,
8+
createSignal,
9+
flush
10+
} from "../src/index.js";
11+
12+
// #4592: `a` and `b` both ask by `s`; `b:0` rejects and `<Errored>` shows
13+
// its fallback. `s` changes and both re-ask. `b:1` landing while `a:1` is
14+
// still out is not a whole frame: the error stays the display until every
15+
// reader the content puts on screen can answer the current `s` (D-39, F-1).
16+
const tick = async () => {
17+
for (let i = 0; i < 2; i++) {
18+
await new Promise(r => setTimeout(r, 0));
19+
flush();
20+
}
21+
};
22+
23+
async function run(loading: boolean) {
24+
const flights = new Map<string, { resolve: (v: number) => void; reject: (e: Error) => void }>();
25+
const ask = (key: string) =>
26+
new Promise<number>((resolve, reject) => flights.set(key, { resolve, reject }));
27+
const [s, setS] = createSignal(0);
28+
const cells: Record<string, unknown> = {};
29+
let shown: unknown;
30+
const frames: string[] = [];
31+
const frame = () =>
32+
shown === "error"
33+
? "error"
34+
: shown === "loading"
35+
? "loading"
36+
: `s=${cells.s}a=${cells.a}b=${cells.b}`;
37+
const dispose = createRoot(dispose => {
38+
const a = createMemo(() => ask("a:" + s()));
39+
const b = createMemo(() => ask("b:" + s()));
40+
const content = () => {
41+
createRenderEffect(s, v => void (cells.s = v));
42+
createRenderEffect(a, v => void (cells.a = v));
43+
createRenderEffect(b, v => void (cells.b = v));
44+
return "content";
45+
};
46+
const view = createErrorBoundary(
47+
() => (loading ? createLoadingBoundary(content, () => "loading") : content()),
48+
() => "error"
49+
);
50+
createRenderEffect(view, v => void (shown = v));
51+
return dispose;
52+
});
53+
await tick();
54+
flights.get("a:0")!.resolve(10);
55+
await tick();
56+
flights.get("b:0")!.reject(new Error("boom"));
57+
await tick();
58+
frames.push(frame());
59+
setS(1);
60+
flush();
61+
await tick();
62+
frames.push(frame());
63+
flights.get("b:1")!.resolve(21);
64+
await tick();
65+
frames.push(frame());
66+
flights.get("a:1")!.resolve(11);
67+
await tick();
68+
frames.push(frame());
69+
dispose();
70+
return frames;
71+
}
72+
73+
it("no Loading: the error stays until every reader answers the new input (#4592)", async () => {
74+
expect(await run(false)).toEqual(["error", "error", "error", "s=1a=11b=21"]);
75+
});
76+
77+
it("inside Loading: the error stays until every reader answers the new input (#4592)", async () => {
78+
expect(await run(true)).toEqual(["error", "error", "error", "s=1a=11b=21"]);
79+
});
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @jsxImportSource @solidjs/web
3+
* @vitest-environment jsdom
4+
*
5+
* #4592: `<Errored>` recovering while another memo in its content is still
6+
* asking for the new input. `a` and `b` both ask by `s`; `b:0` rejects and
7+
* the error fallback shows. `s` changes and both re-ask. `b:1` landing while
8+
* `a:1` is out must not reveal `a`'s answer for `s = 0` beside `s = 1`: the
9+
* error stays the display until the frame that replaces it is whole (F-1,
10+
* D-39, D-41's mirror).
11+
*/
12+
import { render } from "@solidjs/web";
13+
import { createMemo, createSignal, Errored, flush, Loading } from "solid-js";
14+
import { expect, it } from "vitest";
15+
16+
const tick = async () => {
17+
for (let i = 0; i < 2; i++) {
18+
await new Promise(r => setTimeout(r, 0));
19+
flush();
20+
}
21+
};
22+
23+
async function run(boundary: "none" | "loading") {
24+
const flights = new Map<string, { resolve: (v: number) => void; reject: (e: Error) => void }>();
25+
const ask = (key: string) =>
26+
new Promise<number>((resolve, reject) => flights.set(key, { resolve, reject }));
27+
const [s, setS] = createSignal(0);
28+
const el = document.createElement("div");
29+
const frames: string[] = [];
30+
const dispose = render(() => {
31+
const a = createMemo(() => ask("a:" + s()));
32+
const b = createMemo(() => ask("b:" + s()));
33+
const content = () => (
34+
<>
35+
<p>s={s()}</p>
36+
<p>a={a()}</p>
37+
<p>b={b()}</p>
38+
</>
39+
);
40+
return (
41+
<Errored fallback={<p>error</p>}>
42+
{boundary === "loading" ? (
43+
<Loading fallback={<p>loading</p>}>{content()}</Loading>
44+
) : (
45+
content()
46+
)}
47+
</Errored>
48+
);
49+
}, el);
50+
await tick();
51+
flights.get("a:0")!.resolve(10);
52+
await tick();
53+
flights.get("b:0")!.reject(new Error("boom"));
54+
await tick();
55+
frames.push(el.textContent!);
56+
setS(1);
57+
flush();
58+
await tick();
59+
frames.push(el.textContent!); // a:1 and b:1 asked
60+
flights.get("b:1")!.resolve(21);
61+
await tick();
62+
frames.push(el.textContent!); // b recovers; a:1 is still out
63+
flights.get("a:1")!.resolve(11);
64+
await tick();
65+
frames.push(el.textContent!);
66+
dispose();
67+
return frames;
68+
}
69+
70+
it("no boundary: <Errored> recovery does not show a pending memo's stale value beside its new input", async () => {
71+
expect(await run("none")).toEqual(["error", "error", "error", "s=1a=11b=21"]);
72+
});
73+
74+
it("inside <Loading>: <Errored> recovery does not show a pending memo's stale value beside its new input", async () => {
75+
expect(await run("loading")).toEqual(["error", "error", "error", "s=1a=11b=21"]);
76+
});

0 commit comments

Comments
 (0)