Skip to content

Commit 131ceb8

Browse files
ryansolidclaude
andauthored
fix(signals): a merged transaction's verdict lane is the same hold's at the D-28 seat (#4427) (#4455)
* fix(signals): D-28's verdict-seat reset compares holds, not verdict lane objects (#4427) `laneRead`'s D-28 reset (#4275, #4284) makes a leaf seated as a hold's verdict reader leave the seat when it reads a lane that is not that hold's. It decided that by lane identity (`passLane !== l`). A transaction merged into the hold keeps its own verdict lane: a derivation stamped before the merge stays in it. So the leaf read that lane as another hold's. It was served the derivation's staging as the hold's own work (L7'), and its run waited for the hold's landing while the derivation it read was already on screen. The reset now compares the holds. It leaves only when the node is in flight and has never shown, when the lane is not a verdict lane, or when the lane's parent resolves to a different hold than the seat's (D-4: merged holds are one). The seated leaf then reads that lane as the hold's own: the lane's value, the two lanes linked by `enterLane` as for any pass that reads both. Fixes #4427 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore(size): record #4427's cost on the live server-component pages; golf readsHeld's loop `readsHeld` (#4449) now walks its deps as `retryReaches` does (`for (let d = r._deps; d; d = d._nextDep)`), which saves 7 B minified on isPending/latest. Measured locally (linux) over next @ 7135a77. On page: live server components (a frozen floor): 38,764 B brotli / 117,272 B minified, +45 B minified, so the cap goes 38.76 -> 38.78 KB and floor-caps.json's recorded minified 117,227 -> 117,272. On page: compiled live server components: 42,690 / 125,414, so the cap goes 42.67 -> 42.70 KB and the recorded minified 125,374 -> 125,414. Caps are at measured + 10 B rounded up to 0.01 KB. Every other scenario passes the gate. 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 cddaa76 commit 131ceb8

5 files changed

Lines changed: 130 additions & 13 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 render effect seated as a hold's verdict reader no longer leaves the seat when it reads a verdict lane of a transaction merged into that hold: the merged transaction's lane is the same hold's, read as the lane's value and shown with it (#4427).

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,17 @@ export function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any
713713
// a flight — the pass leaves the lane, and its frame holds as if the
714714
// read had come first (S-39, #4275). Nor does a verdict lane's seat carry
715715
// the leaf into another lane (no link): it reads that lane as from the
716-
// frame's seat (#4284).
717-
if ((never || passLane !== l) && passLane?._parent!._verdict === passLane) setPassLane(null);
718-
if (passLane === null || !sameLane(passLane, l)) {
716+
// frame's seat (#4284). The seat is the hold's, not the lane object's: a
717+
// transaction merged into the hold keeps its own verdict lane, and that
718+
// lane is the same hold's (D-4 — merged holds are one; #4427).
719+
const p = passLane;
720+
const seated = p?._parent!._verdict === p;
721+
if (
722+
seated &&
723+
(never || l._parent!._verdict !== l || resolveTx(l._parent!) !== resolveTx(p!._parent!))
724+
)
725+
setPassLane(null);
726+
if (passLane === null || (!seated && !sameLane(passLane, l))) {
719727
// (A lane that has never shown: the screen is the committed value.)
720728
if (never && l._shown) return NOT_PENDING;
721729
if (
@@ -1017,7 +1025,7 @@ function heldBy(t: Transaction, r: Computed<any>): boolean {
10171025
}
10181026
/** `r`'s pass read a node a transaction holds (#4439). */
10191027
function readsHeld(r: Computed<any>): boolean {
1020-
for (let d = r._deps; d !== null; d = d._nextDep) if (d._dep._config & CONFIG_HELD) return true;
1028+
for (let d = r._deps; d; d = d._nextDep) if (d._dep._config & CONFIG_HELD) return true;
10211029
return false;
10221030
}
10231031
const laneSeams = (t: Transaction | null): void => {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* #4427: D-28's verdict-seat reset (#4275, #4284) — a leaf seated as a
3+
* hold's verdict reader leaves the seat for a lane that is not that hold's
4+
* — compared verdict lanes by object identity. A transaction merged into
5+
* the hold keeps its own verdict lane (`verdictLane(t)` is per transaction
6+
* object; a node stamped before the merge stays in it), and that lane is
7+
* the same hold's (D-4: holds that merge are one). Read as another hold's,
8+
* the leaf left the seat and was served the derivation's staging as the
9+
* hold's own work (L7'): its run waited for the hold's landing while the
10+
* derivation it read was already on screen — the same value shown two ways
11+
* on one screen (F-1).
12+
*
13+
* Shape: action A holds `x`, `m = memo(latest(x) * 10)` is its verdict
14+
* lane's; action B holds `y`, and a pass reading both (`k`) merges A into
15+
* B. A leaf `[latest(y), m()]` mounted under B (born held) is seated as B's
16+
* verdict reader by `latest(y)`; A's next write re-derives `m`.
17+
*/
18+
import { expect, it } from "vitest";
19+
import {
20+
action,
21+
createMemo,
22+
createRenderEffect,
23+
createRoot,
24+
createSignal,
25+
flush,
26+
latest
27+
} from "../src/index.js";
28+
29+
const tick = async () => {
30+
for (let i = 0; i < 6; i++) await Promise.resolve();
31+
flush();
32+
};
33+
34+
it("a verdict reader seated in a hold reads a merged transaction's verdict lane as that hold's", async () => {
35+
const [x, setX] = createSignal(0);
36+
const [y, setY] = createSignal(0);
37+
let a1!: () => void, a2!: () => void, b1!: () => void, b2!: () => void;
38+
const actA = action(function* () {
39+
setX(1);
40+
yield new Promise<void>(r => (a1 = r));
41+
setX(2);
42+
yield new Promise<void>(r => (a2 = r));
43+
});
44+
const actB = action(function* () {
45+
setY(1);
46+
yield new Promise<void>(r => (b1 = r));
47+
setY(2);
48+
yield new Promise<void>(r => (b2 = r));
49+
});
50+
let shownM: unknown, leaf: unknown;
51+
createRoot(() => {
52+
const m = createMemo(() => latest(x) * 10);
53+
const k = createMemo(() => x() + y());
54+
createRenderEffect(x, () => {});
55+
createRenderEffect(y, () => {});
56+
createRenderEffect(m, v => {
57+
shownM = v;
58+
});
59+
createRenderEffect(k, () => {});
60+
// <Show when={y() > 0}>{[latest(y), m()]}</Show>
61+
const when = createMemo(() => y() > 0);
62+
const content = createMemo(() => {
63+
if (!when()) return "off";
64+
createRenderEffect(
65+
() => `${latest(y)}/${m()}`,
66+
v => {
67+
leaf = v;
68+
}
69+
);
70+
return "on";
71+
});
72+
createRenderEffect(content, () => {});
73+
});
74+
flush();
75+
actA();
76+
await tick();
77+
expect(shownM).toBe(10);
78+
actB();
79+
await tick();
80+
expect(leaf).toBe("1/10");
81+
82+
// A's next step re-derives `m` in its (merged) verdict lane: the leaf
83+
// shows it with `m`, not at B's landing.
84+
a1();
85+
await tick();
86+
await tick();
87+
expect(shownM).toBe(20);
88+
expect(leaf).toBe("1/20");
89+
90+
b1();
91+
await tick();
92+
await tick();
93+
expect(leaf).toBe("2/20");
94+
b2();
95+
a2();
96+
await tick();
97+
await tick();
98+
expect([shownM, leaf]).toEqual([20, "2/20"]);
99+
});

‎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.83 KB",
20-
"minified": 117331
19+
"cap": "38.85 KB",
20+
"minified": 117376
2121
},
2222
"server: floor (getRequestEvent + isServer)": {
2323
"cap": "1.29 KB",

0 commit comments

Comments
 (0)