Skip to content

Commit 663ecb0

Browse files
ryansolidclaude
andauthored
fix(signals): a verdict reader born into a hold joins it at its re-pass (#4467) (#4471)
* fix(signals): a verdict reader born into a hold joins it at its re-pass (#4467) A memo that read an action's held `x` is born held. When it mounts a `Loading` and calls the function the fallback returned, `latest(x)` runs in the memo's own pass and leaves CONFIG_VERDICT on it (D-25: the posture outlives the pass). At the content's landing the memo re-runs, still born into the hold and never committed, but recompute's held re-pass arm skipped the join for any verdict reader. The flush had no transaction, so the boundary the re-run mounted was not the hold's: it caught its own born-held tree (`freshHook(el, !mount && flushTransaction)`) and showed the fallback. The output then re-derived to the landed content, the memo re-ran, mounted another boundary, and so on without end. A pass born into its hold's world is the hold's own work and reads plainly whatever it asked before (D-25, D-27 #4341; `frameRead` already exempts it through `bornInto`). The held re-pass now joins it too, so the boundary it mounts is the hold's and appears at its commit (D-13): the screen goes from the held frame straight to "1:C". The check sits behind `observeFlightHook`, so bundles without the verdict engine are unchanged. Size: +29 B minified on the isPending/latest scenarios, 0 B elsewhere. page: compiled live server components re-recorded 42.73 -> 42.76 KB. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore(size): re-measure the born-held verdict join over next @ 749b0d7 Live server components 38.85 -> 38.91 KB (117,544; Size-Exception in the PR body), compiled live 42.79 -> 42.83 KB (125,684); isPending/latest and live + router re-record minified with caps unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 --------- Co-authored-by: Claude <[email protected]>
1 parent 230c670 commit 663ecb0

5 files changed

Lines changed: 105 additions & 7 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+
A memo born into a hold that reads `latest()` in its pass (for example by calling a function a `Loading` fallback returned) no longer mounts that `Loading` again and again once the content lands. The memo's re-run is still the hold's own work, so it joins the hold whatever it asked before (D-25), and the boundary it mounts belongs to the hold and appears at its commit (D-13): the screen goes straight to the content.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,14 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
463463
// it joins nothing, so the write that reached it commits mainline.
464464
// `EFFECT_RENDER << 23` is CONFIG_FRAME (a render effect, a boundary's
465465
// tree and output), spelled from the effect type as at creation.
466+
// A verdict reader born into `tx` (`bornInto`: never committed) is the
467+
// hold's own work, whatever it asked before (D-25): it joins like any
468+
// held pass, so what it mounts is the hold's (D-13, #4467).
466469
if (tx._lane || el._config & CONFIG_LAGS) {
467-
} else if (!(el._config & (CONFIG_VERDICT | (EFFECT_RENDER << 23))))
470+
} else if (
471+
!(el._config & (CONFIG_VERDICT | (EFFECT_RENDER << 23))) ||
472+
(observeFlightHook && !(el._config & (EFFECT_RENDER << 23)) && bornInto(el, tx))
473+
)
468474
joinPassTx(tx, freshHook?.(el, el._statusFlags & STATUS_UNINITIALIZED));
469475
else if (
470476
tx !== flushTransaction &&
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* #4467. A Loading mounted during an action's hold by a memo that read the
3+
* held `x` (it joins: born held, D-2). The fallback returns a function, and
4+
* the mount calls it in its own pass. Content lands (50 ms) before the
5+
* action (200 ms).
6+
*
7+
* When the function reads `latest(x)` (directly, or through a memo the
8+
* fallback built), the mount's pass probes: it keeps CONFIG_VERDICT (D-25,
9+
* the posture outlives the pass). At the content's landing the mount
10+
* re-runs — still born into the hold, never committed — and recompute's
11+
* held re-pass did not join the flush to the hold for a verdict reader. So
12+
* the boundary the re-run mounts was not the hold's (D-13): it caught its own
13+
* born-held tree and showed the fallback; the tree then read the landed
14+
* content, the output changed, the mount re-ran and mounted another boundary,
15+
* without end. A pass born in the hold's world is the hold's own work and
16+
* reads plainly whatever it asked before (D-25, D-27 #4341): it joins.
17+
*
18+
* The string-returning forms (`direct`, `innerMemo`) read `latest` only in the
19+
* fallback's own computed (#4337), never in the mount's pass.
20+
*/
21+
import { afterEach, beforeEach, expect, test, vi } from "vitest";
22+
import {
23+
action,
24+
createLoadingBoundary,
25+
createMemo,
26+
createRenderEffect,
27+
createRoot,
28+
createSignal,
29+
flush,
30+
latest,
31+
untrack
32+
} from "../src/index.js";
33+
34+
beforeEach(() => vi.useFakeTimers());
35+
afterEach(() => vi.useRealTimers());
36+
const sleep = (ms: number) => new Promise<void>(r => setTimeout(r, ms));
37+
38+
for (const v of ["direct", "innerMemo", "fnDirect", "fnMemo"] as const)
39+
test(`fallback ${v} under a mount that joined the hold settles on 1:C`, async () => {
40+
const [x, setX] = createSignal(0);
41+
createRoot(() => createRenderEffect(x, () => {}));
42+
flush();
43+
action(function* () {
44+
setX(1);
45+
yield sleep(200);
46+
})();
47+
flush();
48+
let builds = 0;
49+
const screens: unknown[] = [];
50+
createRoot(() => {
51+
const content = createMemo(async () => {
52+
await sleep(50);
53+
return "C";
54+
});
55+
const mount = createMemo(() => {
56+
const v0 = x();
57+
const b = untrack(() =>
58+
createLoadingBoundary(
59+
() => content(),
60+
() => {
61+
builds++;
62+
if (builds > 50) throw new Error("runaway fallback rebuild");
63+
if (v === "direct") return `F${latest(x)}`;
64+
if (v === "fnDirect") return () => `F${latest(x)}`;
65+
const t = createMemo(() => latest(x));
66+
if (v === "fnMemo") return () => `F${t()}`;
67+
return `F${t()}`;
68+
}
69+
)
70+
);
71+
const r: any = b();
72+
return `${v0}:${typeof r === "function" ? r() : r}`;
73+
});
74+
createRenderEffect(mount, s => void screens.push(s));
75+
});
76+
flush();
77+
await vi.advanceTimersByTimeAsync(100);
78+
flush();
79+
await vi.advanceTimersByTimeAsync(200);
80+
flush();
81+
expect(builds).toBe(1);
82+
expect(screens).toEqual(["1:C"]);
83+
});

‎scripts/size/floor-caps.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"minified": 101638
1717
},
1818
"page: live server components (base + live/GET + action + isPending/latest)": {
19-
"cap": "38.85 KB",
20-
"minified": 117514
19+
"cap": "38.91 KB",
20+
"minified": 117544
2121
},
2222
"server: floor (getRequestEvent + isServer)": {
2323
"cap": "1.29 KB",

‎scripts/size/scenarios.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,10 @@ module.exports = [
14441444
// Batch re-record (2026-10-30, over next @ 563b6b0): cap unchanged, recorded minified 30,569 -> 30,596 B (+27 B), measured locally (linux) at 11,092 B brotli. Growth is the 2026-10-30 merges (#4454, #4457, #4461). Recorded minified = measured.
14451445
// D-28's verdict-seat reset compares holds, not lane objects: a seated leaf reading a merged transaction's verdict lane stays the hold's verdict reader (`laneRead`) (#4427, #4455, 2026-10-30, over next @ cddaa76): 11.10 KB -> 11.12 KB, recorded minified 30,596 -> 30,641 B (+45 B), measured locally (linux) at 11,109 B brotli. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
14461446
// A staged error reaches the memos and derived stores that derive from it (#4456, 2026-10-30, re-measured over next @ b773146): 11.12 KB -> 11.17 KB, recorded minified 30,641 -> 30,771 B (+130 B), measured locally (linux) at 11,153 B brotli. The settle walk marks a derivation of a staged error with it, and a derived store's family hears it (D-41), with the verdict engine alone. Correctness; Size-Exception in #4456. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
1447+
// A verdict reader born into a hold joins it at its re-pass (#4471, #4467, 2026-10-30, re-measured over next @ 749b0d7): cap unchanged at 11.17 KB, recorded minified 30,771 -> 30,800 B (+29 B), measured locally (linux) at 11,166 B brotli. Correctness (D-25, D-13); Size-Exception in #4471 for the floor. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
14471448
limit: "11.17 KB",
14481449
// latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 28,693 -> 29,086 B (+343 B minified over next), measured locally (linux) at 10,565 B brotli (+135 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured.
1449-
capMinified: 30771,
1450+
capMinified: 30800,
14501451
alias
14511452
},
14521453
{
@@ -5615,6 +5616,7 @@ module.exports = [
56155616
// A verdict reader born into a hold reads it whichever flush runs it (#4426, D-25/D-27; re-measured over next @ 9c4e4a8): 38.81 KB -> 38.83 KB, recorded minified 117,251 -> 117,331 B, measured locally (linux) at 38,817 B brotli. `stagedScreen`'s held-node check (+20 B minified in core.js) on top of next's +13 B over this floor's record (#4452); the brotli is layout. Correctness; a frozen floor, Size-Exception in the PR body. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
56165617
// D-28's verdict-seat reset compares holds, not lane objects: a seated leaf reading a merged transaction's verdict lane stays the hold's verdict reader (`laneRead`) (#4427, #4455, 2026-10-30, over next @ cddaa76): 38.83 KB -> 38.85 KB, recorded minified 117,331 -> 117,376 B (+45 B), measured locally (linux) at 38,839 B brotli. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
56175618
// A staged error reaches the memos and derived stores that derive from it (#4456, 2026-10-30, re-measured over next @ b773146): cap unchanged at 38.85 KB, recorded minified 117,376 -> 117,514 B (+138 B), measured locally (linux) at 38,849 B brotli. The settle walk marks a derivation of a staged error with it, and a derived store's family hears it (D-41), with the verdict engine alone. Correctness; Size-Exception in #4456. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
5619+
// A verdict reader born into a hold joins it at its re-pass (#4471, #4467, 2026-10-30, re-measured over next @ 749b0d7): 38.85 KB -> 38.91 KB, recorded minified 117,514 -> 117,544 B (+30 B), measured locally (linux) at 38,898 B brotli. Correctness (D-25, D-13); Size-Exception in #4471 for the floor. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
56185620
limit: floorCaps["page: live server components (base + live/GET + action + isPending/latest)"],
56195621
capMinified:
56205622
floorMinified["page: live server components (base + live/GET + action + isPending/latest)"],
@@ -5933,11 +5935,12 @@ module.exports = [
59335935
// D-28's verdict-seat reset compares holds, not lane objects: a seated leaf reading a merged transaction's verdict lane stays the hold's verdict reader (`laneRead`) (#4427, #4455, 2026-10-30, over next @ cddaa76): 42.71 KB -> 42.73 KB, recorded minified 125,478 -> 125,518 B (+40 B), measured locally (linux) at 42,715 B brotli. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
59345936
// #4428 fallback memo lazy (+7 B over next @ ab3d2add, which sits +15 over this record; 2026-10-30): 42.73 KB -> 42.75 KB, recorded minified 125,518 -> 125,540 B (+22 B), measured locally (linux) at 42,735 B brotli. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
59355937
// A staged error reaches the memos and derived stores that derive from it (#4456, 2026-10-30, re-measured over next @ b773146): 42.75 KB -> 42.79 KB, recorded minified 125,540 -> 125,655 B (+115 B), measured locally (linux) at 42,777 B brotli. The settle walk marks a derivation of a staged error with it, and a derived store's family hears it (D-41), with the verdict engine alone. Correctness; Size-Exception in #4456. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
5936-
limit: "42.79 KB",
5938+
// A verdict reader born into a hold joins it at its re-pass (#4471, #4467, 2026-10-30, re-measured over next @ 749b0d7): 42.79 KB -> 42.83 KB, recorded minified 125,655 -> 125,684 B (+29 B), measured locally (linux) at 42,817 B brotli. Correctness (D-25, D-13); Size-Exception in #4471 for the floor. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
5939+
limit: "42.83 KB",
59375940
// An Errored heals when the last reader that caught its error is disposed (#4373, #4384, 2026-10-28, re-recorded over next @ cbc0eebd): recorded minified 123,191 -> 123,249 B (+58 B minified over next's record), measured locally (linux) at 41,899 B brotli. Recorded minified = measured; CI re-bases.
59385941
// Boundary readers keyed by the source they wait on (#4373), with enterLane's tail folded into one else-chain as an offset (-29 B on lane pages) (#4384, 2026-10-28, re-recorded over next @ 1b32ff2e): recorded minified 123,203 -> 123,224 B (+21 B minified over next's record), measured locally (linux) at 41,966 B brotli. Recorded minified = measured; CI re-bases.
59395942
// latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 123,224 -> 123,733 B (+403 B minified over next), measured locally (linux) at 42,119 B brotli (+169 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured.
5940-
capMinified: 125655,
5943+
capMinified: 125684,
59415944
alias: pageAlias
59425945
},
59435946
{
@@ -6340,11 +6343,12 @@ module.exports = [
63406343
// Batch re-record (2026-10-30, over next @ 563b6b0): cap unchanged, recorded minified 142,706 -> 142,735 B (+29 B), measured locally (linux) at 48,365 B brotli. Growth is the 2026-10-30 merges (#4454, #4457, #4461). Recorded minified = measured.
63416344
// D-28's verdict-seat reset compares holds, not lane objects: a seated leaf reading a merged transaction's verdict lane stays the hold's verdict reader (`laneRead`) (#4427, #4455, 2026-10-30, over next @ cddaa76): cap unchanged at 48.44 KB, recorded minified 142,735 -> 142,780 B (+45 B), measured locally (linux) at 48,394 B brotli. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
63426345
// A staged error reaches the memos and derived stores that derive from it (#4456, 2026-10-30, re-measured over next @ b773146): 48.44 KB -> 48.51 KB, recorded minified 142,780 -> 142,918 B (+138 B), measured locally (linux) at 48,498 B brotli. The settle walk marks a derivation of a staged error with it, and a derived store's family hears it (D-41), with the verdict engine alone. Correctness; Size-Exception in #4456. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
6346+
// A verdict reader born into a hold joins it at its re-pass (#4471, #4467, 2026-10-30, re-measured over next @ 749b0d7): cap unchanged at 48.51 KB, recorded minified 142,918 -> 142,947 B (+29 B), measured locally (linux) at 48,462 B brotli. Correctness (D-25, D-13); Size-Exception in #4471 for the floor. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
63436347
limit: "48.51 KB",
63446348
// An Errored heals when the last reader that caught its error is disposed (#4373, #4384, 2026-10-28, re-recorded over next @ cbc0eebd): recorded minified 140,451 -> 140,509 B (+58 B minified over next's record), measured locally (linux) at 47,516 B brotli. Recorded minified = measured; CI re-bases.
63456349
// Boundary readers keyed by the source they wait on (#4373), with enterLane's tail folded into one else-chain as an offset (-29 B on lane pages) (#4384, 2026-10-28, re-recorded over next @ 1b32ff2e): recorded minified 140,463 -> 140,485 B (+22 B minified over next's record), measured locally (linux) at 47,547 B brotli. Recorded minified = measured; CI re-bases.
63466350
// latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 140,485 -> 140,983 B (+405 B minified over next), measured locally (linux) at 47,722 B brotli (+162 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured.
6347-
capMinified: 142918,
6351+
capMinified: 142947,
63486352
alias: pageAlias,
63496353
conditions: solidConditions,
63506354
compile: { hydratable: true }

0 commit comments

Comments
 (0)