Skip to content

Commit 077432b

Browse files
committed
Merge remote-tracking branch 'origin/next' into claude/fix-4629-guess-beside-reask
2 parents 732ca3f + 4235019 commit 077432b

15 files changed

Lines changed: 622 additions & 166 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 `<Errored>` recovery re-arms its subtree: every `<Loading>` under an error fallback counts as not shown, so on recovery it catches what is still pending in the replacement frame and shows its fallback beside the recovered content, instead of the error staying up until the nested content is ready (#4627).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ The optimistic world is the screen plus the action's guesses: derivations of a g
340340

341341
**From:** F-12, F-3, F-1. **Scenarios:** S-38.
342342

343-
An `<Errored>` flipping to its fallback is a boundary going back to its fallback: the nodes behind it stop holding (unless read elsewhere, where they error too), and non-errored nodes that lose their only visible consumer that way stop holding as well. The error stays on screen until a new answer replaces the errored one — a pending is not a value: over `Errored > Loading(never shown)`, a write publishes beside the old error (`0 | Fetch error for 0` → `1 | Fetch error for 0` → `1 | Fetch error for 1`); the inner fallback is hidden behind the error. `Errored` builds its function fallback in its own scope, like `Show`, once per show: a re-derive of the boundary while the fallback shows — a second reader caught, the same error propagated again, a retry pending after `reset()`, a later error — keeps the built fallback, its DOM and focus with it; a later error reaches it through the error accessor; the fallback is disposed once the content that replaces it is on screen — at the commit, when the swap is held (#3991). A fallback that no live reader holds heals: the boundary waits on what threw only while a reader that caught the error is alive, so when the last one is disposed (a `<Show when={isPending(m)}>` closing over `m()` as the action that made `m` throw settles) the content shows again — what a fresh render with the same inputs shows, since nothing on it reads the error (ruled 2026-10-28, #4373).
343+
An `<Errored>` flipping to its fallback is a boundary going back to its fallback: the nodes behind it stop holding (unless read elsewhere, where they error too), and non-errored nodes that lose their only visible consumer that way stop holding as well. The error stays on screen until a new answer replaces the errored one — a pending is not a value: over `Errored > Loading(never shown)`, a write publishes beside the old error (`0 | Fetch error for 0` → `1 | Fetch error for 0` → `1 | Fetch error for 1`); the inner fallback is hidden behind the error. While the fallback shows, nothing under it is on screen, so its recovery re-arms the whole subtree (ruled 2026-11-02, #4627, re-ruling async-gen 91501 #1831): every `<Loading>` under it has not shown content — whether or not it showed content before the error — and once the errored source has its new answer, each catches what is still pending in the replacement frame and shows its fallback beside the recovered content, as on a first load (F-4, D-12): `[Crash][finding related]`. After the recovery the ordinary rules apply: the first content such a `<Loading>` shows makes it a shown boundary, and a later re-ask keeps that content (F-5). The error stays up while something no inner `<Loading>` catches still waits: the errored source's own re-ask (the write above), a pending read directly under the `<Errored>` with no `<Loading>` between (a pending is not a value; #4592), or a recovery that is part of a held write, action or transition, which reveals with that hold (D-41). `Errored` builds its function fallback in its own scope, like `Show`, once per show: a re-derive of the boundary while the fallback shows — a second reader caught, the same error propagated again, a retry pending after `reset()`, a later error — keeps the built fallback, its DOM and focus with it; a later error reaches it through the error accessor; the fallback is disposed once the content that replaces it is on screen — at the commit, when the swap is held (#3991). A fallback that no live reader holds heals: the boundary waits on what threw only while a reader that caught the error is alive, so when the last one is disposed (a `<Show when={isPending(m)}>` closing over `m()` as the action that made `m` throw settles) the content shows again — what a fresh render with the same inputs shows, since nothing on it reads the error (ruled 2026-10-28, #4373).
344344

345-
**Collapses:** §23.1 items 2–3, §27 7b (2026-10-02; the top-level `isPending(count)` affordance was lost by this ruling, knowingly), recovery 9.1–9.3. **Status:** standing. Once per show: `tests/createErrorBoundary.test.ts` ("instantiates the fallback once per show"), `packages/web/test/errored-show-retry-3991.spec.tsx`; the held swap: `tests/boundary-fallback-held-swap-3991.test.ts`; healing when the last reader is disposed: `tests/errored-heal-disposed-reader-4373.test.ts`, `packages/web/test/errored-heal-disposed-reader-4373.spec.tsx`.
345+
**Collapses:** §23.1 items 2–3, §27 7b (2026-10-02; the top-level `isPending(count)` affordance was lost by this ruling, knowingly), recovery 9.1–9.3. **Status:** standing. The recovery re-arm (#4627): `tests/errored-recovery-fresh-loading-4627.test.ts`, `tests/latest-memo-inline-parity.test.ts` (#1831 rows), `packages/web/test/errored-recovery-nested-loading-4425.spec.tsx`, `tests/derived-store-recovery-wake.test.ts` (the store twin, plain and held in an action), the "inside Loading" rows of `tests/errored-recovery-stale-memo-4592.test.ts` and `packages/web/test/errored-recovery-stale-memo-4592.spec.tsx` (their no-boundary rows keep the error: a pending is not a value). A recovery written in an action's tick is the action's and keeps the error up until its hold reveals the inner fallback: the last row of `tests/errored-recovery-fresh-loading-4627.test.ts`, `packages/web/test/async-gen/e1-3289-122.spec.ts` (async-gen 3289 #122). Once per show: `tests/createErrorBoundary.test.ts` ("instantiates the fallback once per show"), `packages/web/test/errored-show-retry-3991.spec.tsx`; the held swap: `tests/boundary-fallback-held-swap-3991.test.ts`; healing when the last reader is disposed: `tests/errored-heal-disposed-reader-4373.test.ts`, `packages/web/test/errored-heal-disposed-reader-4373.spec.tsx`.
346346

347347
---
348348

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ These are the only words the fundamentals use. Internal names (transaction, stag
7272

7373
## F-5. A disarmed boundary forwards: it keeps its content and holds like any reader, until `on` arms it again
7474

75-
**Immutable.** Once a `<Loading>` has shown content it is disarmed: a later refetch or hold does not send it back to its fallback — it keeps the content, and the pending render effects under it are forwarded into the change's hold exactly as if they were read in the open (F-2). The only way back is `on` — a dependency list: a change to anything `on` reads arms the boundary again (F-4), so the render effects under it leave the hold they were forwarded into and the boundary shows its fallback, with the change's frame, until the new content is ready; if nothing under it is pending, nothing happens. The value `on` returns is never compared, and the children are not re-created — they stay alive behind the fallback. A lane is that same hold: the async under a disarmed boundary is forwarded into it, so a display-ahead value and the content move together, exactly as they would with no boundary there.
75+
**Immutable.** Once a `<Loading>` has shown content it is disarmed: a later refetch or hold does not send it back to its fallback — it keeps the content, and the pending render effects under it are forwarded into the change's hold exactly as if they were read in the open (F-2). The only way back is `on` — a dependency list: a change to anything `on` reads arms the boundary again (F-4), so the render effects under it leave the hold they were forwarded into and the boundary shows its fallback, with the change's frame, until the new content is ready; if nothing under it is pending, nothing happens. One exception (D-39): behind a shown error fallback nothing is on screen, so a `<Loading>` there has not shown content — the error boundary's recovery re-arms it, and it catches what is still pending in the replacement frame as on a first load (ruled 2026-11-02, #4627). The value `on` returns is never compared, and the children are not re-created — they stay alive behind the fallback. A lane is that same hold: the async under a disarmed boundary is forwarded into it, so a display-ahead value and the content move together, exactly as they would with no boundary there.
7676

7777
**What it does not say.** It does not say the fallback of a re-arm appears _ahead_ of the change that caused it (F-7: it lands with that change's frame). It does not say a re-arm paints its fallback while its frame waits on the same data read outside the boundary. The boundary is armed; the screen stays on the old content until that hold lifts (D-16).
7878

‎packages/signals/docs/SCENARIOS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ const data = createMemo(() => fetchOrFail(count())); // rejects for every co
909909

910910
`<Errored>` never catches a pending: `ASYNC_OUTSIDE_LOADING_BOUNDARY` is a warning (A6).
911911

912+
Row 1 holds because the errored source itself re-asks. Once it has its new answer, the recovery re-arms the subtree (#4627): the inner `<Loading>`, never shown — or shown before the error — catches what is still pending in the replacement frame, and its fallback shows beside the recovered content. A pending read directly under the `<Errored>` with no `<Loading>` between still keeps the error up, and a recovery held with an action reveals with it (D-41).
913+
912914
### S-42. A held rejection reveals with its frame — D-41 (#3886)
913915

914916
_Pinned: `tests/error-is-an-answer.test.ts`._

‎packages/signals/src/boundaries.ts‎

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,18 @@ const collecting = new Set<Boundary>();
169169
const boundaryOf = (node: Owner): Boundary | undefined =>
170170
node._context[BOUNDARY] as Boundary | undefined;
171171

172+
/** An error boundary at or above `b` shows its fallback: content under it
173+
* is not on screen. */
174+
const behindError = (b: Boundary | null): boolean =>
175+
!!b && ((b._type === STATUS_ERROR && b._fallback) || behindError(b._parent));
176+
172177
/** Catches what reaches it: an error boundary always; a loading one until it
173-
* has shown content, or while re-armed. */
178+
* has shown content, or while re-armed. Behind an error fallback nothing is
179+
* on screen, so the error boundary's recovery re-arms the subtree: a loading
180+
* boundary there has not shown content (D-39, F-4, #4627) — a query; the
181+
* boundary is fresh again once it catches (`caught`). */
174182
const isCollecting = (b: Boundary): boolean =>
175-
b._type === STATUS_ERROR || !b._initialized || b._armed;
183+
b._type === STATUS_ERROR || !b._initialized || b._armed || behindError(b._parent);
176184

177185
/** A reader `b` waits on: recorded for its `on`, and `b` visited at the seam. */
178186
function record(b: Boundary, node: Computed<any>, source = node): void {
@@ -200,14 +208,14 @@ function caught(b: Boundary, node: Computed<any>, error: unknown, source = node)
200208
setSignal(b._error!, caught);
201209
reportClientError(caught, b._owner, source);
202210
}
211+
// A loading boundary that catches has not shown content: fresh until it
212+
// does — already so unless it caught behind an error fallback, which the
213+
// recovery leaves catching (D-39, #4627); a re-arm's `flip` says it too.
214+
else b._initialized = false;
203215
record(b, node, source);
204-
// A loading fallback behind an error fallback is hidden: the error stays
205-
// the display until what the fallback waits on answers (D-39) — the
206-
// error boundary waits on it too.
207-
// (`_type`: STATUS_PENDING 1 < STATUS_ERROR 2 — an error boundary above a
208-
// loading one.)
209-
for (let p: Boundary | null = b; (p = p._parent); )
210-
if (p._fallback && p._type > b._type) record(p, node);
216+
// A loading boundary behind an error fallback that catches a pending
217+
// holds nothing above it: the error boundary's recovery shows its
218+
// fallback beside the recovered content (D-39, #4627).
211219
if (b._armed) flip(b);
212220
// Already showing the fallback: one more reader to wait on changes
213221
// nothing on screen. The fallback is instantiated once per show — a later
@@ -340,6 +348,19 @@ function release(b: Boundary): void {
340348
b._runs = null;
341349
}
342350

351+
/** `r`, held by error boundary `b` for the error `s` threw, is pending
352+
* again after `s` answered, and a loading boundary between them that has
353+
* not shown content catches it: that boundary is its display, beside the
354+
* recovered content (D-39, F-4, #4627). Not while that boundary's swap to
355+
* its fallback is staged in a hold (a recovery written in an action's tick):
356+
* the error stays up until the hold reveals both (D-41, F-1). */
357+
function caughtBelow(b: Boundary, r: Computed<any>, s: Computed<any>): boolean {
358+
if (!(s._statusFlags & (STATUS_ERROR | STATUS_PENDING) || r._statusFlags & STATUS_ERROR))
359+
for (let l: Boundary | null | undefined = boundaryOf(r); l && l !== b; l = l._parent)
360+
if (l._type & STATUS_PENDING && isCollecting(l)) return !(l._output!._config & CONFIG_HELD);
361+
return false;
362+
}
363+
343364
/** Drop the readers that settled or died. Settled: a loading reader no
344365
* longer pending; an error's source neither errored nor in flight. A reader
345366
* that landed but is held (its value staged in a transaction) is not: the
@@ -349,7 +370,9 @@ function release(b: Boundary): void {
349370
* error boundary (`_type` is the status it catches) — on the reader or its
350371
* source. A reader pending again after the source that threw answered (it
351372
* re-asks through a memo that carried the error) has no new answer yet: the
352-
* error stays the display (D-39: a pending is not a value; async-gen 91501
373+
* error stays the display (D-39: a pending is not a value) — unless a loading
374+
* boundary under the error one catches it (`caughtBelow`): the recovery shows
375+
* with that boundary's fallback (ruled 2026-11-02, #4627; async-gen 91501
353376
* #1831).
354377
*
355378
* `pass` 0: a reader clearing asks whether it was the last (`catchStatus`),
@@ -369,7 +392,8 @@ export function prune(b: Boundary, pass?: boolean | 0): number {
369392
// settled before it ran, a fresh boundary revealed into a hold its
370393
// pass then went pending in, which waited on that flight (#4568).
371394
if (
372-
(r._statusFlags | s._statusFlags) & mask ||
395+
((r._statusFlags | s._statusFlags) & mask &&
396+
!(mask & STATUS_ERROR && caughtBelow(b, r, s))) ||
373397
(mask & STATUS_ERROR && s._config & CONFIG_STAGED_ERROR) ||
374398
(r._config & CONFIG_VERDICT && r._flags & REACTIVE_IN_HEAP)
375399
) {

‎packages/signals/tests/derived-store-recovery-wake.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ import {
2121
// the derive's status is cleared before its landing pass. The landing is
2222
// still the derive's change for that reader (memo parity, F-12/D-39: a new
2323
// answer replaces the error): the reader re-runs and commits the value.
24+
// `m0` (the errored source) answers at once; `m1` only carried its error, and
25+
// its re-ask is caught by the Loading the recovery re-arms (ruled 2026-11-02,
26+
// #4627, the #1831 re-ruling's store twin): `loading`, then the value. Held
27+
// in an action, the error stays up through the hold (D-41) and the Loading's
28+
// fallback shows at the commit, since an armed Loading's pending holds
29+
// nothing outside it (F-4).
2430
describe("a derived store's landing wakes a reader parked on its error", () => {
2531
const settle = async () => {
2632
for (let i = 0; i < 4; i++) {
@@ -91,10 +97,7 @@ describe("a derived store's landing wakes a reader parked on its error", () => {
9197
for (const how of ["action", "write"] as const) {
9298
it(`${how}: the store's reader commits the recovered value, as the memo's does`, async () => {
9399
const memo = await run("memo", how);
94-
// The error stays the display until the new answer lands (D-39: a
95-
// pending is not a value): the content shows with the reader's value,
96-
// in one flush, never with the reader still loading.
97-
expect(memo).toEqual(["error", "v:5", "content"]);
100+
expect(memo).toEqual(["error", "loading", "v:5", "content"]);
98101
expect(await run("store", how)).toEqual(memo);
99102
});
100103
}

0 commit comments

Comments
 (0)