Skip to content

Commit 3086f1b

Browse files
ryansolidClaude via Cursorcursoragent
authored
fix(signals): a staged read of a node born staged is not re-queued at the lane seam (#3882)
Since #3869, verdict-lane work that read a staging of the flush is re-derived on the committed world while the frame stays parked (`stagedReaders`, the lane seam). A node born into the parked frame has no committed value: the re-run reads the same staging, registers again, and the seam re-queues it every round until flush throws "Potential Infinite Loop Detected" (semantic fuzzer, mount-under-hold: a `latest()`-gated Show mounting a fresh Loading under an action hold, 29 cases across seeds 3289 and 91501). `stagedRead` keeps REACTIVE_STAGED_READ for such a read but no longer lists the pass for re-derivation. The frames return to pre-#3869's (the content shows the held value while held; A29's fallback frame is still open, pinned as test.fails). Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent bc51ada commit 3086f1b

4 files changed

Lines changed: 121 additions & 5 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+
Fix an infinite flush loop ("Potential Infinite Loop Detected") when a `latest()`-gated `Show` mounts a fresh `Loading` under an action hold: lane work that reads a node born staged is no longer re-queued to re-derive on a committed value it doesn't have.

‎packages/signals/docs/RULES-INDEX.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
7373
| A26 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:109` | — | action-await-contract.test.ts×2 fuzz-findings-l2.test.ts×1 posture-store-parity.test.ts×2 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled 2026-07-17] An ambient transaction window is one flush; parking is flush-driven — (**ruled 2026-07-17**, #2913; **enforcement hardened 2026-08-31**, #3141 — parking is flush-driven, and a trans… |
7474
| A27 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:299` | — | loading-value.test.ts×2 visibility-oracle.states.ts×18 visibility-oracle.test.ts×1 | [ruled 2026-08-10] The commit-#0 loading window is loading-class and verdict-quiet — (**ruled 2026-08-10**) **The commit-#0 loading window is loading-class and verdict-quiet.** A node born committed v… |
7575
| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:93` | constants.ts×1 core.ts×12 lanes.ts×2 scheduler.ts×3 types.ts×1 verdict.ts×2 store.ts×4 | createOptimistic.test.ts×5 fuzz-findings-l2.test.ts×6 held-derivation-not-a-proposal-3612.test.ts×1 issue-3800-repro.test.ts×1 latest-held-till-flush.test.ts×1 posture-store-parity.test.ts×5 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 optimistic-draft-visibility-3665.test.ts×5 optimistic-list-mutation-matrix.harness.ts×1 optimistic-list-mutation-matrix.test.ts×2 shallow.test.ts×1 woken-transaction-adopts-staged-bump.test.ts×1 treeshake.test.ts×2 verdict-contract.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… |
76-
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:117` | boundaries.ts×1 action.ts×1 async.ts×1 constants.ts×1 core.ts×13 effect.ts×1 lanes.ts×1 scheduler.ts×4 signals.ts×1 store.ts×1 | adoption-unchanged-key-read-3706.test.ts×9 body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 boundary-not-born-held-3540.test.ts×4 createProjection.draft-lifetime-3585.test.ts×1 direct-commit-readers-posture.test.ts×1 fuzz-findings-l2.test.ts×6 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 held-truth-lane-only.test.ts×3 l2-contract.test.ts×1 latest-held-till-flush.test.ts×2 loading-fallback-in-flush-3540.test.ts×6 loading-on-frame-following-3540.test.ts×1 mount-over-foreign-hold-3761.test.ts×1 optimistic-mount-nested-memo-3835.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×3 posture-born-held-and-observation.test.ts×1 posture-store-parity.test.ts×6 derived-presence-async-3726.test.ts×3 optimistic-untracked-reads-f3-f5.test.ts×1 store-unchanged-read-independent-write-3688.test.ts×1 tick-scoped-pass-transaction.test.ts×2 treeshake.test.ts×3 verdict-mount-first-pass-3851.test.ts×2 visibility-oracle-store.states.ts×5 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … |
76+
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:117` | boundaries.ts×1 action.ts×1 async.ts×1 constants.ts×1 core.ts×13 effect.ts×1 lanes.ts×1 scheduler.ts×4 signals.ts×1 store.ts×1 | adoption-unchanged-key-read-3706.test.ts×9 body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 boundary-not-born-held-3540.test.ts×4 createProjection.draft-lifetime-3585.test.ts×1 direct-commit-readers-posture.test.ts×1 fuzz-findings-l2.test.ts×6 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 held-truth-lane-only.test.ts×3 l2-contract.test.ts×1 latest-held-till-flush.test.ts×2 loading-fallback-in-flush-3540.test.ts×6 loading-on-frame-following-3540.test.ts×1 mount-over-foreign-hold-3761.test.ts×1 optimistic-mount-nested-memo-3835.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×3 posture-born-held-and-observation.test.ts×1 posture-store-parity.test.ts×6 derived-presence-async-3726.test.ts×3 optimistic-untracked-reads-f3-f5.test.ts×1 store-unchanged-read-independent-write-3688.test.ts×1 tick-scoped-pass-transaction.test.ts×2 treeshake.test.ts×3 verdict-mount-first-pass-3851.test.ts×2 verdict-mount-loading-flush-loop.test.ts×2 visibility-oracle-store.states.ts×5 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … |
7777
| A30 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:255` | async.ts×3 attribution.ts×1 constants.ts×1 core.ts×1 effect.ts×1 lanes.ts×1 scheduler.ts×5 | async-landing-deps-3461.test.ts×3 fuzz-findings-l2.test.ts×3 held-conditional-effect.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 ispending-in-boundary-on-3528.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-frame-held-lane-3662.test.ts×1 posture-born-held-and-observation.test.ts×1 treeshake.test.ts×2 write-proposals-3494.test.ts×2 zombie-rerun-after-commit-3546.test.ts×2 | [ruled 2026-09-13 (#3410)] A memo's dependencies are the committed frame's until the frame is replaced — A pass that _staged_ its value has not replaced the committed frame, so the committed value sti… |
7878
| A31 | live | `docs/SPEC-ASYNC-SEMANTICS.md:129` | boundaries.ts×1 core.ts×1 lanes.ts×1 verdict.ts×2 | fuzz-findings-l2.test.ts×6 ispending-combined-atomic-3442.test.ts×1 | [live 2026-09-14 (#3442)] A memo computes under its own lane posture, never its puller's — A memo's value is one shared slot every reader sees, so its pass runs under the lane posture the memo itself … |
7979
| A32 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:137` | core.ts×4 lanes.ts×1 store.ts×1 | visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 | [ruled 2026-09-14] Children-forbidden readers see the frame, not the graph — `createTrackedEffect` and `onSettled` callbacks are effect-phase code that runs after the frame is decided. They read the f… |

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ export function serve(el: Signal<any> | Computed<any>, c: Computed<any> | null):
18581858
stagedScreen(c!)
18591859
)
18601860
return el._value;
1861-
stagedRead(c!);
1861+
stagedRead(c!, el);
18621862
return el._pendingValue;
18631863
}
18641864

@@ -1870,10 +1870,16 @@ export function serve(el: Signal<any> | Computed<any>, c: Computed<any> | null):
18701870
* the committed world and its lane's runs wait that round, so the held
18711871
* write never shows through the lane. A verdict lane's work likewise: the
18721872
* lane holds verdicts, not the frame's other stagings (#3851) — except a
1873-
* verdict reader, which answered for itself (the lane seam, lanes.ts). */
1874-
export function stagedRead(c: Computed<any>): void {
1873+
* verdict reader, which answered for itself (the lane seam, lanes.ts). Not
1874+
* a read of a node born staged: it has no committed value to re-derive on,
1875+
* and a re-run would read the same staging and re-queue every round. */
1876+
export function stagedRead(c: Computed<any>, el?: Signal<any> | Computed<any>): void {
18751877
c._flags |= REACTIVE_STAGED_READ;
1876-
if (passLane !== null) stagedReaders.push(c);
1878+
if (
1879+
passLane !== null &&
1880+
!((el as Computed<any> | undefined)?._statusFlags! & STATUS_UNINITIALIZED)
1881+
)
1882+
stagedReaders.push(c);
18771883
}
18781884

18791885
/** A10 for a staged node: a verdict reader (the pass entered a window) that
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* A verdict reader mounts a fresh Loading under an action hold (semantic
3+
* fuzzer, mount-under-hold seed 3289 cases 119 and 323).
4+
*
5+
* `<Show when={latest(x) > 0}>` (gated through a memo) opens while an action
6+
* holds `x`, and mounts a `<Loading>` whose content reads `x` directly with
7+
* no load of its own. The boundary's output is born into the held frame, so
8+
* it has no committed value; the render effect inserting it is verdict-lane
9+
* work that read its staging. Since #3869 the seam re-queued that effect to
10+
* re-derive on the committed world every round the frame stayed parked, and
11+
* each re-run read the same staging: "Potential Infinite Loop Detected".
12+
*/
13+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
14+
import {
15+
action,
16+
createLoadingBoundary,
17+
createMemo,
18+
createRenderEffect,
19+
createRoot,
20+
createSignal,
21+
flush,
22+
latest,
23+
untrack
24+
} from "../src/index.js";
25+
26+
beforeEach(() => vi.useFakeTimers());
27+
afterEach(() => vi.useRealTimers());
28+
29+
const resolve = (v: unknown): unknown => {
30+
while (typeof v === "function") v = (v as () => unknown)();
31+
return v;
32+
};
33+
34+
function mount(anchor: boolean) {
35+
const [x, setX] = createSignal(0);
36+
const screen = { x: undefined as number | undefined, slot: undefined as unknown };
37+
createRoot(() => {
38+
if (anchor)
39+
createRenderEffect(x, v => {
40+
screen.x = v;
41+
});
42+
const condition = createMemo(() => latest(x) > 0);
43+
const children = createMemo(() =>
44+
condition()
45+
? untrack(() =>
46+
createLoadingBoundary(
47+
() => untrack(() => () => `content ${x()}`),
48+
() => "fallback"
49+
)
50+
)
51+
: undefined
52+
);
53+
createRenderEffect(
54+
() => resolve(children()),
55+
v => {
56+
screen.slot = v;
57+
}
58+
);
59+
});
60+
flush();
61+
const committed = () => (anchor ? screen.x : untrack(x));
62+
let release!: () => void;
63+
const hold = () =>
64+
action(function* () {
65+
setX(1);
66+
yield new Promise<void>(r => (release = r));
67+
})();
68+
return { screen, committed, hold, release: () => release() };
69+
}
70+
71+
describe("a verdict reader mounts a fresh Loading under an action hold", () => {
72+
for (const anchor of [false, true])
73+
describe(anchor ? "with a reader of x on screen (case 323)" : "case 119", () => {
74+
test("flush settles while held, and the commit reveals the content", async () => {
75+
const m = mount(anchor);
76+
expect(m.screen.slot).toBeUndefined();
77+
expect(m.committed()).toBe(0);
78+
79+
const done = m.hold();
80+
expect(() => flush()).not.toThrow();
81+
await Promise.resolve();
82+
expect(() => flush()).not.toThrow();
83+
expect(m.committed()).toBe(0);
84+
85+
m.release();
86+
await done;
87+
flush();
88+
expect(m.committed()).toBe(1);
89+
expect(m.screen.slot).toBe("content 1");
90+
});
91+
92+
// A29: a fresh, never-shown Loading over held data shows its fallback
93+
// now. Pre-#3869 behavior, still open (MH1): the content shows the held
94+
// value beside the committed `x = 0`.
95+
test.fails("while held, the fresh boundary shows its fallback (A29)", async () => {
96+
const m = mount(anchor);
97+
m.hold();
98+
flush();
99+
await Promise.resolve();
100+
flush();
101+
expect(m.committed()).toBe(0);
102+
expect(m.screen.slot).toBe("fallback");
103+
});
104+
});
105+
});

0 commit comments

Comments
 (0)