Skip to content

Commit 0f5daf3

Browse files
committed
Merge origin/next (62745f6, with #4560) into fix/release-after-retry-4474
scripts/size takes next's side; the ledger is re-recorded from CI in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
2 parents 4e6cacd + 62745f6 commit 0f5daf3

33 files changed

Lines changed: 1481 additions & 222 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+
fix(signals): `defer: true` skips an effect's first run when a held update mounts it (#4543)
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>` boundary over a list no longer reveals the list from before the error when the error's replacement lands held with an action (a guess on the errored store re-asked it): the error stays until that action's frame reveals, instead of showing the previous question's rows.

‎.changeset/floor-shared-walks.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solidjs/signals": patch
3+
"@solidjs/web": patch
4+
---
5+
6+
Shrink the compiled and hand-written floors: the dependent walks, dependency clearing, status writes, effect-run queueing, flatten's thunk walk and the delegated-event parent hop share their code (no behavior change).
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 keyed optimistic store's arrangement guess written while its derive asks a new question (an input changed, not a `refresh()`) is re-based over that question's answer, like an older truth (#4525). Before, the answer folded beneath the guess, so the rows the guess had only carried over from the old answer stayed on screen; under `<Loading on={filter()}>` the region left its fallback showing the new input beside the old list minus the guess until the action's refresh landed.
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+
Keep observing a pending store query when a later optimistic guess re-runs an existing reader, so bindings (shared or separate) do not show the new query's inputs beside rows from the previous answer, and the new answer's rows never show beside the old query for a frame when it lands.
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+
fix(signals): a re-pass equal to a first value already staged this flush is not a change, so a non-keyed `Show` over an async condition no longer remounts its child when the child writes the source on mount (#4540)

‎.changeset/staged-signed-zero.md‎

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+
Preserve signed zero and pending-state atomicity when a derivation reads a staged signal write accepted by a custom comparator.
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+
fix(signals): a pending memo nothing reads no longer holds a fresh `<Loading>` when its subtree mounts under a held update (#4542)

‎packages/signals/src/boundaries.ts‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,17 @@ function catchStatus(
255255
// effect reporting its own status. An error boundary records an effect
256256
// only while it is errored, and a staged error keeps STATUS_ERROR on a
257257
// node that had it (`stageError`), so `prune`'s CONFIG_STAGED_ERROR case
258-
// cannot reach this path (#4364).
259-
if (collecting.size !== 0)
258+
// cannot reach this path (#4364). "Last" is judged as the seam would
259+
// (`prune`): readers the same held pass disposed — a list re-mapped
260+
// under its parked pass drops the rows that read the error — are gone,
261+
// and left for the seam, they revealed the stale content outside the
262+
// hold (#4526).
263+
if (collecting.size)
260264
for (let b: Boundary | null | undefined = boundaryOf(node); b; b = b._parent)
261265
if (
262266
!((b._readers.get(node)?._statusFlags as number) & (b._type | STATUS_PENDING)) &&
263267
b._readers.delete(node) &&
264-
b._readers.size === 0
268+
!prune(b, 0)
265269
) {
266270
if (b._fallback) redraw(b);
267271
if (revealHooks && b._reveal !== null) revealHooks._changed(b._reveal);
@@ -339,8 +343,13 @@ function release(b: Boundary): void {
339343
* source. A reader pending again after the source that threw answered (it
340344
* re-asks through a memo that carried the error) has no new answer yet: the
341345
* error stays the display (D-39: a pending is not a value; async-gen 91501
342-
* #1831). */
343-
export function prune(b: Boundary, pass: boolean): number {
346+
* #1831).
347+
*
348+
* `pass` 0: a reader clearing asks whether it was the last (`catchStatus`),
349+
* once per clear. The first reader kept by its status ends the walk — one
350+
* is left — and the ones behind it wait for a later prune, so a recovery of
351+
* N readers walks each once, not N²/2 times (#4526). */
352+
export function prune(b: Boundary, pass?: boolean | 0): number {
344353
const mask = b._type | STATUS_PENDING;
345354
for (const [r, s] of b._readers) {
346355
if (!((r._flags | s._flags) & REACTIVE_DISPOSED)) {
@@ -351,8 +360,10 @@ export function prune(b: Boundary, pass: boolean): number {
351360
if (
352361
(r._statusFlags | s._statusFlags) & mask ||
353362
(mask & STATUS_ERROR && s._config & CONFIG_STAGED_ERROR)
354-
)
363+
) {
364+
if (pass === 0) break;
355365
continue;
366+
}
356367
if (
357368
(s !== b._tree || b._armed) &&
358369
(s._config & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD
@@ -388,7 +399,7 @@ export function ready(b: Boundary): boolean {
388399
b._tree._config & CONFIG_HELD &&
389400
(b._output === null || b._output._statusFlags & STATUS_UNINITIALIZED)
390401
) &&
391-
prune(b, false) === 0)
402+
prune(b) === 0)
392403
);
393404
}
394405

@@ -404,7 +415,7 @@ function boundarySeam(): void {
404415
}
405416
// A parked frame's boundary (zombie) keeps its state for its revival.
406417
if (flags & REACTIVE_ZOMBIE) continue;
407-
prune(b, false);
418+
prune(b);
408419
const o = b._output!;
409420
// A fallback staged into the very hold its readers landed in folds back
410421
// (D-16, U-9): the content is ready when that hold commits (D-15). Not

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

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,13 @@ export function setPendingError(el: Computed<any>, source?: Computed<any>, error
120120
if (el._x !== null) el._x._error = null;
121121
return;
122122
}
123-
if (error instanceof NotReadyError && error.source === source) {
124-
ext(el)._error = error;
125-
return;
126-
}
127-
const current = el._x?._error;
128-
if (!(current instanceof NotReadyError) || current.source !== source) {
129-
ext(el)._error = new NotReadyError(source);
130-
}
123+
// The given error when it names this source, else the current one when it
124+
// does (rewritten unchanged), else a fresh one.
125+
const current = error instanceof NotReadyError && error.source === source ? error : el._x?._error;
126+
ext(el)._error =
127+
current instanceof NotReadyError && current.source === source
128+
? current
129+
: new NotReadyError(source);
131130
}
132131

133132
export function forEachDependent(
@@ -137,6 +136,25 @@ export function forEachDependent(
137136
for (let s = el._subs; s !== null; s = s._nextSub) fn(s._sub, s);
138137
}
139138

139+
/** Each dependent reachable from `el`, depth first. `fn` sees every arrival,
140+
* `seen` when an earlier branch already walked the node (a diamond); the
141+
* node's dependents are walked once, on its first arrival unless `fn`
142+
* returns false (then it stays unmarked: a later branch may walk it). */
143+
function walkDependents(
144+
el: Computed<any>,
145+
fn: (node: Computed<any>, seen: boolean) => unknown
146+
): void {
147+
const visited = new NewSet<Computed<any>>();
148+
const visit = (node: Computed<any>) => {
149+
const seen = visited.has(node);
150+
if (fn(node, seen) !== false && !seen) {
151+
visited.add(node);
152+
forEachDependent(node, visit);
153+
}
154+
};
155+
forEachDependent(el, visit);
156+
}
157+
140158
// Queue a node to re-run on the next flush (used both when a pending source
141159
// settles and when an `isPending` observer must re-evaluate after a real error):
142160
// shared scheduling helper in heap.ts (tracked effects bypass the heap).
@@ -169,14 +187,9 @@ export function releaseIfSettledUnobserved(node: Computed<any>): void {
169187
// Collect-then-release so unobserved() never unlinks under the walk.
170188
export function releaseSettledDependents(el: Computed<any>): void {
171189
let candidates: Computed<any>[] | undefined;
172-
const visited = new NewSet<Computed<any>>();
173-
const visit = (node: Computed<any>) => {
174-
if (visited.has(node)) return;
175-
visited.add(node);
176-
if (!node._subs && node._config & CONFIG_AUTO_DISPOSE) (candidates ??= []).push(node);
177-
forEachDependent(node, visit);
178-
};
179-
forEachDependent(el, visit);
190+
walkDependents(el, (node, seen) => {
191+
if (!seen && !node._subs && node._config & CONFIG_AUTO_DISPOSE) (candidates ??= []).push(node);
192+
});
180193
if (candidates) for (const node of candidates) releaseIfSettledUnobserved(node);
181194
}
182195

@@ -264,17 +277,12 @@ function stageMark(node: Computed<any>, el: Computed<any>): void {
264277

265278
export function settleErroredDependents(el: Computed<any>, error: any): void {
266279
let scheduled = false;
267-
const visited = new NewSet<Computed<any>>();
268-
const visit = (node: Computed<any>) => {
269-
if (visited.has(node)) return;
270-
visited.add(node);
271-
if (node._x?._error === error) {
280+
walkDependents(el, (node, seen) => {
281+
if (!seen && node._x?._error === error) {
272282
enqueueSub(node);
273283
scheduled = true;
274284
}
275-
forEachDependent(node, visit);
276-
};
277-
forEachDependent(el, visit);
285+
});
278286
if (scheduled) schedule();
279287
}
280288

@@ -342,10 +350,12 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
342350
removePendingSource(el, source);
343351
let scheduled = false;
344352
let released: Computed<any>[] | undefined;
345-
const visited = new NewSet<Computed<any>>();
346-
const settle = (node: Computed<any>) => {
353+
walkDependents(el, (node, seen) => {
347354
if (
348-
visited.has(node) ||
355+
// A node an earlier branch settled (a diamond) takes only this early
356+
// return's verdict re-run / staged-error mark, as the walk did before
357+
// it was shared.
358+
seen ||
349359
// A conditional dropped this source, but another dependency can still
350360
// carry it. Only retire pending state inherited through the recovered
351361
// branch. Deliberately NOT marked visited on this early return: the
@@ -363,11 +373,11 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
363373
// D-41: a derivation of a staged error carries it (`stageMark`).
364374
return (
365375
holdWorkHook &&
366-
(node._config & CONFIG_VERDICT
367-
? enqueueSub(node)
368-
: el._config & CONFIG_STAGED_ERROR && stageMark(node, el))
376+
(node._config & CONFIG_VERDICT
377+
? enqueueSub(node)
378+
: el._config & CONFIG_STAGED_ERROR && stageMark(node, el)),
379+
false
369380
);
370-
visited.add(node);
371381
node._time = clock;
372382
const remaining = node._x?._pendingSources?.values().next().value;
373383
// STATUS_ERROR + pending sources only coexist via an errored loading
@@ -402,10 +412,7 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
402412
// lists this walk is still iterating.
403413
if (!node._subs && node._config & CONFIG_AUTO_DISPOSE) (released ??= []).push(node);
404414
}
405-
forEachDependent(node, settle);
406-
};
407-
408-
forEachDependent(el, settle);
415+
});
409416

410417
// A node the enqueueSub above queued is released at that pass's tail
411418
// (`releaseIfSettledUnobserved`, REACTIVE_RELEASE_AFTER): the landing's
@@ -1000,34 +1007,27 @@ export function notifyStatus(el: Computed<any>, status: number, error?: any): vo
10001007
const pendingSource = status === STATUS_PENDING && error instanceof NotReadyError && error.source;
10011008
// (CARVE 2: the lane assignment went with the engine.)
10021009

1003-
if (status === STATUS_PENDING && pendingSource) {
1010+
if (pendingSource) {
10041011
// D-41: a re-ask of a shown error keeps it the display (`_shownError`).
10051012
if (el._statusFlags & STATUS_ERROR) el._x!._shownError = el._x!._error;
10061013
addPendingSource(el, pendingSource);
1007-
// A re-ask of an error that answered the first read: still no value.
1008-
el._statusFlags =
1009-
STATUS_PENDING |
1010-
(el._statusFlags & STATUS_NO_VALUE
1014+
} else clearPendingSources(el);
1015+
// An error answering a node with no value marks it so; a re-ask of it
1016+
// (pending, from a source or not) is uninitialized again — still no
1017+
// value; a write (STATUS_NONE) gives it one.
1018+
el._statusFlags =
1019+
status |
1020+
(status === STATUS_ERROR
1021+
? el._statusFlags & (STATUS_UNINITIALIZED | STATUS_NO_VALUE)
1022+
? STATUS_NO_VALUE
1023+
: 0
1024+
: status === STATUS_PENDING && el._statusFlags & STATUS_NO_VALUE
10111025
? STATUS_UNINITIALIZED
10121026
: el._statusFlags & STATUS_UNINITIALIZED);
1013-
// Preserve the current source on this propagation so readers park on
1014-
// the distinct pending source.
1015-
setPendingError(el, pendingSource, error);
1016-
} else {
1017-
clearPendingSources(el);
1018-
// An error answering a node with no value marks it so; a re-ask of it
1019-
// (pending) is uninitialized again; a write (STATUS_NONE) gives it one.
1020-
el._statusFlags =
1021-
status |
1022-
(status === STATUS_ERROR
1023-
? el._statusFlags & (STATUS_UNINITIALIZED | STATUS_NO_VALUE)
1024-
? STATUS_NO_VALUE
1025-
: 0
1026-
: status === STATUS_PENDING && el._statusFlags & STATUS_NO_VALUE
1027-
? STATUS_UNINITIALIZED
1028-
: el._statusFlags & STATUS_UNINITIALIZED);
1029-
ext(el)._error = error;
1030-
}
1027+
// A propagated pending keeps its current source so readers park on the
1028+
// distinct pending source.
1029+
if (pendingSource) setPendingError(el, pendingSource, error);
1030+
else ext(el)._error = error;
10311031

10321032
// Lanes: a written guess is an optimistic boundary (A17 — "the optimistic
10331033
// future value until we know otherwise"). Its own source in flight is its
@@ -1108,7 +1108,7 @@ export function propagateStatus(el: Computed<any>, status: number, error: any):
11081108
// frame still passes through — its pass is the frame's (#3372, compiled
11091109
// shape: the unmount it stages makes the observer a zombie whose say is
11101110
// moot for this transaction, A15 #3463).
1111-
if (status === STATUS_PENDING && pendingSource && sub._x?._pendingSources?.has(pendingSource)) {
1111+
if (pendingSource && sub._x?._pendingSources?.has(pendingSource)) {
11121112
if (
11131113
passLane === null &&
11141114
(sub._config & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD &&
@@ -1119,7 +1119,7 @@ export function propagateStatus(el: Computed<any>, status: number, error: any):
11191119
return;
11201120
}
11211121
if (
1122-
(status === STATUS_PENDING && pendingSource) ||
1122+
pendingSource ||
11231123
(status !== STATUS_PENDING && (sub._x?._error !== error || sub._x?._pendingSources))
11241124
) {
11251125
// The marked subscriber is queued for the commit sweep so its status

0 commit comments

Comments
 (0)