Skip to content

Commit 9f050c9

Browse files
committed
fix(signals): trim the #4527 fix by 11 B minified on store rows, 4 B elsewhere
- store: link the pass the staged error is thrown into whether the pull is tracked or not (a tracked read links anyway, and `link` dedupes). This drops the `tracking` test, and `c &&` replaces `c !== null`. - boundaries: an error boundary is born `_initialized` (the field is loading-only: no other error-boundary path reads it), so prune's #3540 clause stays as it was. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent 9d1f5e6 commit 9f050c9

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎.changeset/error-boundary-superseded-staged-error-4527.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
An error boundary no longer hands its reader an error that was superseded inside the same transition (#4527). Here is the case: an action keeps its transition open, the store's re-ask is rejected (that rejection is staged, D-41), and a second re-ask answers before the commit. An effect whose compute created `createErrorBoundary(() => store, …)` used to get the fallback at the commit and never ran again. Now it gets the answer, as the screen does.
66

7-
Two changes make that work. First, a memo returning a derived store's proxy is linked to the store's derive when the untracked shape probe throws it a staged error, so the re-ask and the answer that supersede the error reach the memo. Second, an error boundary that has not shown content reveals a recovery that lands in the hold it caught the error in together with that hold's commit, instead of keeping its fallback past it.
7+
Two changes make that work. First, a pass that a derived store's pull throws a staged error into is now linked to the store's derive, including the untracked shape probe of a returned proxy. That way the re-ask and the answer that supersede the error reach the memo. Second, an error boundary no longer waits for first content: one that has not shown content reveals a recovery that lands in the hold it caught the error in together with that hold's commit, instead of keeping its fallback past it.

‎packages/signals/src/boundaries.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,12 @@ export function prune(b: Boundary, pass: boolean): number {
363363
// lane's reader reveals with the lane, this round.) A boundary that
364364
// has not shown content catches it instead: the fallback stays until
365365
// the reader is committed (#3540: what a fresh boundary catches holds
366-
// nothing outside it). Not an error boundary: what it caught in a hold
367-
// was that hold's staged error (D-41), and an answer landing in the
368-
// same hold replaces it there — the content reveals with the commit,
369-
// and nothing ever shows the superseded error (D-39, #4527).
370-
if (!pass || (!b._initialized && b._type & STATUS_PENDING)) continue;
366+
// nothing outside it). Not an error boundary (born `_initialized`):
367+
// what it caught in a hold was that hold's staged error (D-41), and an
368+
// answer landing in the same hold replaces it there — the content
369+
// reveals with the commit, and nothing ever shows the superseded
370+
// error (D-39, #4527).
371+
if (!pass || !b._initialized) continue;
371372
joinFuture(txOf(s));
372373
}
373374
}
@@ -615,7 +616,8 @@ function createBoundary<T>(
615616
_tree: null!,
616617
_output: null,
617618
_readers: new Map(),
618-
_initialized: false,
619+
// Loading only: an error boundary has no first-content wait (`prune`).
620+
_initialized: type === STATUS_ERROR,
619621
_armed: false,
620622
_armLane: null,
621623
_lane: null,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,11 @@ function pullFamily(target: StoreTarget): void {
18851885
// flight the family has — not over a new question they do not answer
18861886
// (optimistic.ts `stands`, #4336).
18871887
if (verdict === null && fw._statusFlags & STATUS_PENDING && optHooks?.stands(target)) return;
1888-
// An untracked pull inside a pass that throws it a staged error (D-41) —
1889-
// `handleAsync` asking a returned proxy whether it is a flight — links
1890-
// the pass, as a tracked read does (#4519): the pass carries the error,
1891-
// and the re-ask or answer that supersedes it must reach it (#4527).
1892-
if (!tracking && c !== null && fw._config & CONFIG_STAGED_ERROR) link(fw, c);
1888+
// A pass the pull throws a staged error (D-41) is linked to the derive,
1889+
// untracked too — `handleAsync` asking a returned proxy whether it is a
1890+
// flight: the pass carries the error, and the re-ask or answer that
1891+
// supersedes it must reach it (#4527; a tracked read links anyway, #4519).
1892+
if (c && fw._config & CONFIG_STAGED_ERROR) link(fw, c);
18931893
readNode(fw);
18941894
} else {
18951895
untrack(() => readNode(fw));

0 commit comments

Comments
 (0)