Skip to content

Commit 66c6f56

Browse files
ryansolidclaude
andauthored
fix(signals): writes that net to the committed value hold no errored re-run (#4452)
* fix(signals): writes that net to the committed value hold no errored re-run (D-8) A plain write then an action writing the signal back to its committed value in one tick made no proposal (D-8), but the memo it re-ran read the signal's staging (equal to the committed value) as a read of the frame's future (REACTIVE_STAGED_READ). An errored memo's re-run then staged its new error (D-41) and the seam held it with the action, since a re-run's error is never equal to the shown one: isPending(m) read true for as long as the action stayed open (F-9), while an identity memo over it read false. A staging equal to the committed value is now read as the screen. Found by the async-gen rerun on next 5e68925 (E2). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore(size): raise caps for the netted-write read +13 B minified on every bundle that keeps the signal read path (the staging-equals-committed check in `read`); the brotli growth past it is layout. Raised the five non-frozen caps that crossed, at measured + 10 B rounded up to 0.01 KB with recorded minified = measured. The three frozen floors it crosses (hydrating no stores +5 B, base page +45 B, live page +81 B over cap) stay within the 20 B minified allowance and are not raised. 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 7135a77 commit 66c6f56

5 files changed

Lines changed: 112 additions & 11 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+
Writes that net to a signal's committed value in one tick no longer hold an errored memo's re-run with an action, so `isPending` of it stays `false` (D-8).

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,9 @@ export function read<T>(el: Signal<T> | Computed<T>): T {
20272027
if (__TEST__) shadowActual(SLOT_C);
20282028
return el._value as T;
20292029
}
2030-
stagedRead(c as Computed<any>);
2030+
// A staging equal to the committed value is writes that netted (D-8): no
2031+
// proposal, so not a read of the frame's future.
2032+
if (el._pendingValue !== el._value) stagedRead(c as Computed<any>);
20312033
if (__TEST__) shadowActual(SLOT_P);
20322034
return el._pendingValue as T;
20332035
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* D-8 + F-9: a tick whose writes net to the committed value made no
3+
* proposal, so nothing that derives from it pends. Async-gen rerun on next
4+
* 5e68925c (E2): `m0 = memo(s0 !%4=2)` is errored at `s0 = 1`; `s0 = 2`
5+
* then an action writing `s0 = 1` in the same tick re-runs `m0`, which
6+
* throws again. Its pass read the signal's staging — equal to the committed
7+
* value — so the error was staged and the seam held it with the action
8+
* (a re-run's error is never equal to the shown one): `isPending(m0)` read
9+
* `true` for as long as the action stayed open, where an identity memo over
10+
* it read `false`.
11+
*/
12+
import { afterEach, expect, it } from "vitest";
13+
import {
14+
action,
15+
createMemo,
16+
createRenderEffect,
17+
createRoot,
18+
createSignal,
19+
flush,
20+
isPending,
21+
resetErrorHalt
22+
} from "../src/index.js";
23+
24+
afterEach(() => resetErrorHalt());
25+
26+
const tick = async () => {
27+
await new Promise(r => setTimeout(r, 0));
28+
flush();
29+
};
30+
31+
for (const identity of [false, true])
32+
it(`writes that net to the committed value pend nothing over an errored memo${identity ? " (through an identity memo)" : ""}`, async () => {
33+
const [s, setS] = createSignal(1);
34+
let m!: () => number;
35+
const seen: boolean[] = [];
36+
const dispose = createRoot(d => {
37+
const m0 = createMemo(() => {
38+
const v = s() + 1;
39+
if (v % 4 === 2) throw new Error(`m0:${v}`);
40+
return v;
41+
});
42+
m = identity ? createMemo(() => m0()) : m0;
43+
createRenderEffect(
44+
() => isPending(m),
45+
v => void seen.push(v)
46+
);
47+
return d;
48+
});
49+
flush();
50+
const act = action(function* () {
51+
setS(1);
52+
yield new Promise(() => {});
53+
});
54+
setS(2);
55+
act();
56+
await tick();
57+
expect(seen).toEqual([false]);
58+
expect(isPending(m)).toBe(false);
59+
dispose();
60+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @vitest-environment jsdom
3+
*/
4+
// async-gen rerun on next 5e68925c, seed 3289 (E2): over an errored memo, a
5+
// plain write then an action that nets it back to the committed value in one
6+
// tick made no proposal (D-8), so `isPending(m0)` stays false (F-9) and the
7+
// `Show` it gates never opens. The memo read directly opened it (the re-run's
8+
// error was held with the action); through an identity memo it did not.
9+
import { expect, test } from "vitest";
10+
import { runScenario } from "./run.js";
11+
12+
const minimized = {
13+
signals: [1],
14+
memos: [{ async: false, deps: [{ src: { k: "s", i: 0 }, how: "plain" }], poison: 2 }],
15+
tree: {
16+
t: "show",
17+
when: { how: "pending", src: { k: "m", i: 0 } },
18+
child: { t: "leaf", text: [], attrs: [], grouped: true },
19+
fallback: false
20+
},
21+
steps: [{ t: "write", s: 0, v: 2 }, { t: "action", s: 0, v: 1 }, { t: "task" }]
22+
} as any;
23+
24+
test("minimized: writes that net to the committed value open no isPending gate", async () => {
25+
const direct = await runScenario(minimized, {});
26+
const identity = await runScenario(minimized, { identity: true });
27+
expect(direct.screens).toEqual(identity.screens);
28+
expect(direct.screens).toEqual(["", "", "", ""]);
29+
});

‎scripts/size/scenarios.js‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,9 @@ module.exports = [
11171117
// 14.89 KB, recorded minified 43,874 -> 43,875 B; CI-measured at 14,875 B
11181118
// (43,875 B minified). Lower only: cap at measured + 10 B rounded up to
11191119
// 0.01 KB; recorded minified never raised.
1120-
limit: "14.89 KB",
1121-
capMinified: 43875,
1120+
// A tick whose writes net to the committed value pends no errored re-run (D-8, async-gen rerun on 5e68925c) (2026-10-30, over next @ 7135a77a): 14.89 -> 14.95 KB, recorded minified 43,875 -> 43,888 B (+13 B), measured locally (linux) at 14,932 B brotli. A signal read whose staging equals its committed value is not a read of the frame's future (`read`): +13 B minified, the rest brotli layout. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
1121+
limit: "14.95 KB",
1122+
capMinified: 43888,
11221123
alias
11231124
},
11241125
{
@@ -3032,8 +3033,9 @@ module.exports = [
30323033
// B; CI-measured at 13,416 B (37,014 B minified). Lower only: cap at
30333034
// measured + 10 B rounded up to 0.01 KB; recorded minified never raised.
30343035
// Batch re-record (2026-10-30, next @ 32163a9, size job 123956613767): cap unchanged, recorded minified 37,014 -> 37,015 B, measured in CI at 13,423 B brotli. Growth is the 2026-10-30 merges (#4424, #4436, #4416, #4442); #4416's truncation sweep is the +19 B minified on the hydrating scenarios. Cap at measured + 10 B rounded up to 0.01 KB where over; recorded minified = measured.
3035-
limit: "13.43 KB",
3036-
capMinified: 37015,
3036+
// A tick whose writes net to the committed value pends no errored re-run (D-8, async-gen rerun on 5e68925c) (2026-10-30, over next @ 7135a77a): 13.43 -> 13.47 KB, recorded minified 37,015 -> 37,028 B (+13 B), measured locally (linux) at 13,451 B brotli. A signal read whose staging equals its committed value is not a read of the frame's future (`read`): +13 B minified, the rest brotli layout. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
3037+
limit: "13.47 KB",
3038+
capMinified: 37028,
30373039
alias
30383040
},
30393041
{
@@ -3890,8 +3892,9 @@ module.exports = [
38903892
// 29.74 KB, recorded minified 88,302 -> 88,303 B; CI-measured at 29,727 B
38913893
// (88,303 B minified). Lower only: cap at measured + 10 B rounded up to
38923894
// 0.01 KB; recorded minified never raised.
3893-
limit: "29.74 KB",
3894-
capMinified: 88303,
3895+
// A tick whose writes net to the committed value pends no errored re-run (D-8, async-gen rerun on 5e68925c) (2026-10-30, over next @ 7135a77a): 29.74 -> 29.78 KB, recorded minified 88,303 -> 88,316 B (+13 B), measured locally (linux) at 29,762 B brotli. A signal read whose staging equals its committed value is not a read of the frame's future (`read`): +13 B minified, the rest brotli layout. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
3896+
limit: "29.78 KB",
3897+
capMinified: 88316,
38953898
alias: observeAlias
38963899
},
38973900
// Compiled-template scenarios (2026-10-05): the four `app:` fixtures above
@@ -4128,8 +4131,9 @@ module.exports = [
41284131
// 26.27 KB, recorded minified 79,985 -> 79,986 B; CI-measured at 26,257 B
41294132
// (79,986 B minified). Lower only: cap at measured + 10 B rounded up to
41304133
// 0.01 KB; recorded minified never raised.
4131-
limit: "26.27 KB",
4132-
capMinified: 79986,
4134+
// A tick whose writes net to the committed value pends no errored re-run (D-8, async-gen rerun on 5e68925c) (2026-10-30, over next @ 7135a77a): 26.27 -> 26.31 KB, recorded minified 79,986 -> 79,999 B (+13 B), measured locally (linux) at 26,294 B brotli. A signal read whose staging equals its committed value is not a read of the frame's future (`read`): +13 B minified, the rest brotli layout. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
4135+
limit: "26.31 KB",
4136+
capMinified: 79999,
41334137
alias
41344138
},
41354139
{
@@ -4301,8 +4305,9 @@ module.exports = [
43014305
// 32.43 KB, recorded minified 100,729 -> 100,748 B; CI-measured at 32,419 B
43024306
// (100,748 B minified). Lower only: cap at measured + 10 B rounded up to
43034307
// 0.01 KB; recorded minified never raised.
4304-
limit: "32.43 KB",
4305-
capMinified: 100748,
4308+
// A tick whose writes net to the committed value pends no errored re-run (D-8, async-gen rerun on 5e68925c) (2026-10-30, over next @ 7135a77a): 32.43 -> 32.52 KB, recorded minified 100,748 -> 100,761 B (+13 B), measured locally (linux) at 32,508 B brotli. A signal read whose staging equals its committed value is not a read of the frame's future (`read`): +13 B minified, the rest brotli layout. Correctness. Cap at measured + 10 B rounded up to 0.01 KB; recorded minified = measured.
4309+
limit: "32.52 KB",
4310+
capMinified: 100761,
43064311
alias
43074312
},
43084313
{

0 commit comments

Comments
 (0)