Skip to content

Commit 873bd4e

Browse files
Merge branch 'next' into fix/claim-after-attributes
Keep the caps #3884 just landed. The overlapping compiled scenarios are remeasured on the combination before this lands. Co-authored-by: Cursor <[email protected]>
2 parents 44676fc + f6905dc commit 873bd4e

5 files changed

Lines changed: 256 additions & 26 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+
isPending and latest on a superseded write do not depend on reads inside the parked computation.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
309309
// landing). A frame born into the transaction (uninitialized: never run,
310310
// A29) keeps staging: live writes keep it current, it effects at the
311311
// swap (ruling A).
312+
// A pending flight is the transition's own work (#3884). A probe on an
313+
// earlier pass left CONFIG_VERDICT, and a frame read here would serve the
314+
// committed screen, settle the flight and drop the hold — a superseding
315+
// write's verdict would depend on that probe. Cleared for this pass; a
316+
// probe in the body re-stamps it after the plain reads.
317+
if (el._statusFlags & STATUS_PENDING) el._config &= ~CONFIG_VERDICT;
312318
if (el._config & CONFIG_HELD) {
313319
const tx = txOf(el);
314320
// Held by a blocked lane: the frame joins nothing — a lane never holds
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/**
2+
* #3884: isPending/latest on a superseded write must not depend on whether the
3+
* parked computation also reads them.
4+
*
5+
* Under #3774, verdict readers see the committed screen. The "nothing" row is
6+
* the consistent answer, and every other variant must match it. An outside
7+
* `isPending(source)` read is true for as long as the superseding write is
8+
* parked.
9+
*/
10+
import { describe, expect, it } from "vitest";
11+
import {
12+
createMemo,
13+
createRenderEffect,
14+
createRoot,
15+
createSignal,
16+
flush,
17+
isPending,
18+
latest,
19+
untrack
20+
} from "../src/index.js";
21+
22+
const tick = () => new Promise(r => setTimeout(r, 0));
23+
24+
type Extra =
25+
| "nothing"
26+
| "untracked latest"
27+
| "untracked isPending"
28+
| "tracked latest"
29+
| "tracked isPending";
30+
31+
const EXTRAS: Extra[] = [
32+
"nothing",
33+
"untracked latest",
34+
"untracked isPending",
35+
"tracked latest",
36+
"tracked isPending"
37+
];
38+
39+
function readExtra(source: () => string, extra: Extra): void {
40+
if (extra === "untracked latest") untrack(() => latest(source));
41+
if (extra === "untracked isPending") untrack(() => isPending(source));
42+
if (extra === "tracked latest") latest(source);
43+
if (extra === "tracked isPending") isPending(source);
44+
}
45+
46+
type Checkpoint = {
47+
label: string;
48+
effect: string;
49+
isPending: boolean;
50+
latest?: string;
51+
};
52+
53+
/** The value the UI effect is showing at this point in the log. */
54+
function effectAt(log: string[], index: number): string {
55+
let effect = "(none)";
56+
for (let i = 0; i <= index; i++) {
57+
const line = log[i];
58+
if (line.startsWith("effect: ")) effect = line.slice("effect: ".length);
59+
}
60+
return effect;
61+
}
62+
63+
function checkpoints(log: string[]): Checkpoint[] {
64+
const out: Checkpoint[] = [];
65+
for (let i = 0; i < log.length; i++) {
66+
const line = log[i];
67+
if (!line.startsWith("| ")) continue;
68+
const pending = /isPending=(true|false)/.exec(line);
69+
const latestMatch = /latest=([^ ]+)/.exec(line);
70+
if (!pending) throw new Error(`checkpoint missing isPending: ${line}`);
71+
out.push({
72+
label: line.slice(2, line.indexOf(":")),
73+
effect: effectAt(log, i),
74+
isPending: pending[1] === "true",
75+
...(latestMatch ? { latest: latestMatch[1] } : {})
76+
});
77+
}
78+
return out;
79+
}
80+
81+
/**
82+
* Narrowed repro (rc.14 comment): the parked memo reads `source` directly and
83+
* the UI effect reads the verdicts directly.
84+
*
85+
* Baseline "nothing": effect `/slow1` when A parks, `/slow2` at B's flush,
86+
* `-` when B lands; outside isPending true from A parked until B lands.
87+
*/
88+
async function runNarrowed(extra: Extra): Promise<string[]> {
89+
const log: string[] = [];
90+
const gates: Record<string, PromiseWithResolvers<string>> = {};
91+
const gate = (k: string) => (gates[k] ??= Promise.withResolvers<string>());
92+
const [source, setSource] = createSignal("/");
93+
94+
createRoot(() => {
95+
const data = createMemo(() => {
96+
const v = source();
97+
readExtra(source, extra);
98+
return v.startsWith("/slow") ? gate(v).promise : v;
99+
});
100+
createRenderEffect(data, () => {});
101+
createRenderEffect(
102+
() => (isPending(source) ? latest(source) : "-"),
103+
v => void log.push(`effect: ${v}`)
104+
);
105+
});
106+
flush();
107+
const cp = (label: string) => log.push(`| ${label}: isPending=${isPending(source)}`);
108+
109+
setSource("/slow1");
110+
flush();
111+
cp("A parked");
112+
await tick();
113+
setSource("/slow2");
114+
flush();
115+
cp("B flushed");
116+
await tick();
117+
cp("B flushed +tick");
118+
gates["/slow1"].resolve("one");
119+
await tick();
120+
cp("A resolved");
121+
gates["/slow2"].resolve("two");
122+
await tick();
123+
cp("B resolved");
124+
return log;
125+
}
126+
127+
/**
128+
* Original repro: a `path` memo between source and the parked memo, and the
129+
* effect behind a `target` memo.
130+
*
131+
* Baseline "nothing": effect shows `/slow2` at B's flush; outside isPending
132+
* true while B is parked.
133+
*/
134+
async function runOriginal(extra: Extra): Promise<string[]> {
135+
const log: string[] = [];
136+
const gates: Record<string, PromiseWithResolvers<string>> = {};
137+
const gate = (k: string) => (gates[k] ??= Promise.withResolvers<string>());
138+
const [source, setSource] = createSignal("/");
139+
140+
createRoot(() => {
141+
const path = createMemo(() => source());
142+
const data = createMemo(() => {
143+
const v = path();
144+
readExtra(source, extra);
145+
return v.startsWith("/slow") ? gate(v).promise : v;
146+
});
147+
createRenderEffect(data, () => {});
148+
const target = createMemo(() => (isPending(source) ? latest(source) : "-"));
149+
createRenderEffect(target, v => void log.push(`effect: ${v}`));
150+
});
151+
flush();
152+
const cp = (label: string) =>
153+
log.push(`| ${label}: isPending=${isPending(source)} latest=${latest(source)}`);
154+
155+
setSource("/slow1");
156+
flush();
157+
cp("A parked");
158+
await tick();
159+
setSource("/slow2");
160+
flush();
161+
cp("B flushed");
162+
await tick();
163+
cp("B flushed +tick");
164+
gates["/slow1"].resolve("one");
165+
await tick();
166+
cp("A resolved");
167+
gates["/slow2"].resolve("two");
168+
await tick();
169+
cp("B resolved");
170+
return log;
171+
}
172+
173+
/** What "nothing" shows. Every variant must match this. */
174+
const NARROWED: Checkpoint[] = [
175+
{ label: "A parked", effect: "/slow1", isPending: true },
176+
{ label: "B flushed", effect: "/slow2", isPending: true },
177+
{ label: "B flushed +tick", effect: "/slow2", isPending: true },
178+
{ label: "A resolved", effect: "/slow2", isPending: true },
179+
{ label: "B resolved", effect: "-", isPending: false }
180+
];
181+
182+
const ORIGINAL: Checkpoint[] = [
183+
{ label: "A parked", effect: "/slow1", isPending: true, latest: "/slow1" },
184+
{ label: "B flushed", effect: "/slow2", isPending: true, latest: "/slow2" },
185+
{ label: "B flushed +tick", effect: "/slow2", isPending: true, latest: "/slow2" },
186+
{ label: "A resolved", effect: "/slow2", isPending: true, latest: "/slow2" },
187+
{ label: "B resolved", effect: "-", isPending: false, latest: "/slow2" }
188+
];
189+
190+
describe("#3884 superseded-transition verdicts", () => {
191+
describe("narrowed repro", () => {
192+
for (const extra of EXTRAS) {
193+
it(`${extra} matches the nothing baseline`, async () => {
194+
const log = await runNarrowed(extra);
195+
expect(checkpoints(log), log.join(" ; ")).toEqual(NARROWED);
196+
});
197+
}
198+
});
199+
200+
describe("original repro", () => {
201+
for (const extra of EXTRAS) {
202+
it(`${extra} matches the nothing baseline`, async () => {
203+
const log = await runOriginal(extra);
204+
expect(checkpoints(log), log.join(" ; ")).toEqual(ORIGINAL);
205+
});
206+
}
207+
});
208+
});

‎scripts/size/floor-caps.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"minified": 20316
55
},
66
"app: render + one signal (the simple-app floor)": {
7-
"cap": "9.93 KB",
8-
"minified": 27872
7+
"cap": "9.94 KB",
8+
"minified": 27895
99
},
1010
"app: hydrating (no stores) with Show/For/Loading/Errored/lazy": {
11-
"cap": "17.91 KB",
12-
"minified": 52977
11+
"cap": "17.93 KB",
12+
"minified": 52998
1313
},
1414
"page: base server components (hydrating + dynamic + frames + sf reference)": {
1515
"cap": "34.22 KB",

‎scripts/size/scenarios.js‎

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,10 @@ module.exports = [
10161016
// chained target reads through to the inner store (`serveDataKey`). Cap
10171017
// set at measured + 10 B rounded up to 0.01 KB. Accepted by the maintainer
10181018
// 2026-10-07: store scenarios only, hello world unchanged.
1019-
limit: "14.70 KB",
1020-
capMinified: 44637,
1019+
// #3884 (2026-10-08): measured at 14,707 B brotli / 44,669 B minified by CI
1020+
// (Size run 37873447222). Cap set to that brotli size, rounded up to 0.01 KB.
1021+
limit: "14.71 KB",
1022+
capMinified: 44669,
10211023
alias
10221024
},
10231025
{
@@ -1497,6 +1499,9 @@ module.exports = [
14971499
// at measured + 10 B rounded up to 0.01 KB. Accepted by the maintainer
14981500
// 2026-10-07 on the condition hello world stays under 10 KB. The cap is
14991501
// frozen again at 9.93 KB.
1502+
// Size-Exception (#3884, 2026-10-08): 9.93 -> 9.94 KB, measured at 9,936 B
1503+
// brotli / 27,895 B minified by CI (Size run 37873447222). Cap set to that
1504+
// brotli size, rounded up to 0.01 KB. Hello world stays under 10 KB.
15001505
limit: floorCaps["app: render + one signal (the simple-app floor)"],
15011506
capMinified: floorMinified["app: render + one signal (the simple-app floor)"],
15021507
alias
@@ -1853,6 +1858,9 @@ module.exports = [
18531858
// (`liveTx`, `holdNode`). Cap set at measured + 10 B rounded up to 0.01 KB.
18541859
// Accepted by the maintainer 2026-10-07 on the condition hello world stays
18551860
// under 10 KB. The cap is frozen again at 17.91 KB.
1861+
// Size-Exception (#3884, 2026-10-08): 17.91 -> 17.93 KB, measured at 17,922 B
1862+
// brotli / 52,998 B minified by CI (Size run 37873447222). Cap set to that
1863+
// brotli size, rounded up to 0.01 KB.
18561864
limit: floorCaps["app: hydrating (no stores) with Show/For/Loading/Errored/lazy"],
18571865
capMinified: floorMinified["app: hydrating (no stores) with Show/For/Loading/Errored/lazy"],
18581866
alias
@@ -2325,6 +2333,7 @@ module.exports = [
23252333
// condition hello world stays under 10 KB.
23262334
// #3892 (2026-10-08): measured at 29,252 B brotli / 92,410 B minified by CI
23272335
// (Size run 37873440136). Cap set to that brotli size, rounded up to 0.01 KB.
2336+
// #3884 stacks on this; its combined size is remeasured before merge.
23282337
limit: "29.26 KB",
23292338
capMinified: 92410,
23302339
alias
@@ -2856,8 +2865,10 @@ module.exports = [
28562865
// into it while it is live (`liveTx`, `holdNode`). Cap set at measured + 10
28572866
// B rounded up to 0.01 KB. Accepted by the maintainer 2026-10-07 on the
28582867
// condition hello world stays under 10 KB.
2859-
limit: "14.53 KB",
2860-
capMinified: 41284,
2868+
// #3884 stacked on next (2026-10-08): measured at 14,552 B brotli / 41,305 B minified
2869+
// by CI (Size run 37877131031). Cap set to that brotli size, rounded up to 0.01 KB.
2870+
limit: "14.56 KB",
2871+
capMinified: 41305,
28612872
alias: observeAlias
28622873
},
28632874
{
@@ -3395,8 +3406,10 @@ module.exports = [
33953406
// condition hello world stays under 10 KB.
33963407
// #3892 (2026-10-08): measured at 25,263 B brotli / 79,149 B minified by CI
33973408
// (Size run 37873440136). Cap set to that brotli size, rounded up to 0.01 KB.
3398-
limit: "25.27 KB",
3399-
capMinified: 79149,
3409+
// #3884 stacked on next (2026-10-08): measured at 25,293 B brotli / 79,170 B minified
3410+
// by CI (Size run 37877131031). Cap set to that brotli size, rounded up to 0.01 KB.
3411+
limit: "25.30 KB",
3412+
capMinified: 79170,
34003413
alias
34013414
},
34023415
{
@@ -3473,8 +3486,10 @@ module.exports = [
34733486
// chained target reads through to the inner store (`serveDataKey`). Cap
34743487
// set at measured + 10 B rounded up to 0.01 KB. Accepted by the maintainer
34753488
// 2026-10-07: store scenarios only, hello world unchanged.
3476-
limit: "31.17 KB",
3477-
capMinified: 99672,
3489+
// #3884 (2026-10-08): measured at 31,195 B brotli / 99,702 B minified by CI
3490+
// (Size run 37873447222). Cap set to that brotli size, rounded up to 0.01 KB.
3491+
limit: "31.20 KB",
3492+
capMinified: 99702,
34783493
alias
34793494
},
34803495
{
@@ -4594,13 +4609,11 @@ module.exports = [
45944609
// adoption-time claim index from the frames eager note. Cap set at
45954610
// measured + 10 B rounded up to 0.01 KB. Accepted by the maintainer
45964611
// (2026-10-08, "perf is important enough — it's the point here").
4597-
// #3924's claim-after-attributes growth is remeasured on this cap.
4598-
// #3923 (2026-10-08): measured at 40,934 B brotli / 123,574 B minified by CI
4599-
// (Size run 37873448792). Cap set to that brotli size, rounded up to 0.01 KB.
4600-
// #3923 stacked on next (2026-10-08): measured at 41,009 B brotli / 123,702 B minified
4601-
// by CI (Size run 37877141123). Cap set to that brotli size, rounded up to 0.01 KB.
4602-
limit: "41.01 KB",
4603-
capMinified: 123702,
4612+
// #3884 stacked on next (2026-10-08): measured at 41,057 B brotli / 123,713 B minified
4613+
// by CI (Size run 37877131031). Cap set to that brotli size, rounded up to 0.01 KB.
4614+
// #3923 stacks on this landed cap; the combination is remeasured before merge.
4615+
limit: "41.06 KB",
4616+
capMinified: 123713,
46044617
alias: pageAlias
46054618
},
46064619
{
@@ -4807,13 +4820,11 @@ module.exports = [
48074820
// landed at 47.19 KB; CI on this merge (Size run 37852899252) measured
48084821
// 47,281 B / 143,158 minified (+197 B brotli / +354 B minified over
48094822
// #3913's 47,084 / 142,804). Cap at measured + 10 B rounded up to 0.01 KB.
4810-
// #3924's claim-after-attributes growth is remeasured on this cap.
4811-
// #3923 (2026-10-08): measured at 47,287 B brotli / 143,229 B minified by CI
4812-
// (Size run 37873448792). Cap set to that brotli size, rounded up to 0.01 KB.
4813-
// #3923 stacked on next (2026-10-08): measured at 47,358 B brotli / 143,360 B minified
4814-
// by CI (Size run 37877141123). Cap set to that brotli size, rounded up to 0.01 KB.
4815-
limit: "47.36 KB",
4816-
capMinified: 143360,
4823+
// #3884 stacked on next (2026-10-08): measured at 47,306 B brotli / 143,256 B minified
4824+
// by CI (Size run 37877131031). Cap set to that brotli size, rounded up to 0.01 KB.
4825+
// #3923 stacks on this landed cap; the combination is remeasured before merge.
4826+
limit: "47.31 KB",
4827+
capMinified: 143256,
48174828
alias: pageAlias,
48184829
conditions: solidConditions,
48194830
compile: { hydratable: true }

0 commit comments

Comments
 (0)