Skip to content

Commit 62b0a22

Browse files
ryansolidClaude via Cursorcursoragent
committed
fix(signals): a render effect that stops reading a pending memo releases the memo's source (fuzzer #3446 P1)
A pending REPORTER that recovers without its flight landing — its pass no longer reads the source (a show() gate closed) — stops counting for the transaction it reported to (A15 / #3426: the hold lasts while a live reporter observes the flight). `reporterBlocksSource` already judged the re-run effect dead; nothing RE-JUDGED the parked transaction, since the flush that re-ran the effect had no active transaction, and the writes held with it stayed staged for as long as the flight stayed up — forever, for one that never lands. recompute's tail now treats that recovery as the completion event it is and wakes the transaction (wokenTransitions — the third site after disposal #3372 and boundary reset #3375), skipped under the transaction's own flush, which judges the landing itself. Reporters are stamped, so no unstamped fallback is needed. Found by the semantic fuzzer (#3446, law P1, 21/1000 cases in one symptom group, case 854); reproduced as the posture matrix's `effect × gatedAway` cell on the "observed only by the matrix reader" state — the memo-between variant (`memo × gatedAway`) already released, which is what narrowed it to the direct-effect reporter. Pin flipped from it.fails; spec O3 fixed. +100 B minified (24,478 -> 24,578). Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 3a09d3f commit 62b0a22

7 files changed

Lines changed: 110 additions & 49 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 that stops reading a pending async memo no longer keeps the memo's source held. A pending reporter that recovers without its flight landing — its pass no longer reads the source, e.g. a `show()` gate closed — is a completion event for the transaction it reported to: `recompute` now wakes that parked transaction (`wokenTransitions`, the third site after disposal #3372 and boundary reset #3375) so it is re-judged and its held writes commit. Before, `reporterBlocksSource` already judged the effect dead but nothing re-asked the parked transaction, and an ordinary write to the source stayed staged for as long as the flight stayed up — forever when it never landed. Found by the semantic fuzzer (#3446, law P1, 21/1000 cases) and reproduced as the posture matrix's `effect × gatedAway` cell.

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

Lines changed: 10 additions & 10 deletions
Large diffs are not rendered by default.

‎packages/signals/docs/SPEC-ASYNC-SEMANTICS.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,13 @@ An error escaping every boundary permanently halts the system with `REACTIVITY_H
308308
**Current behavior:** a memo + render effect created inside a live action's body over a value another action holds (or over the superseded / body-ended states) direct-commits (`recompute`'s `create && bornHeld === null` arm — `stagedEntry` is only recorded when `activeTransition` is null) and its render effect publishes the held value, while untracked reads keep the committed frame until both actions settle. Mainline creation over the same value is born held (A29's creation-time form, 2026-09-14). Creation inside the HOLDING action's own body is unaffected: the body's write is unflushed (A28), the creation reads the committed frame.
309309
**Tension:** A29 (born held) applies to mainline creation only; the "isn't visible" premise does not hold for a render effect created in the body. A future ruling either extends A29 to every posture (`creatingPass` in `enterStagedRead`, prototyped 2026-09-15: +83 B, suite green) or states creation-escapes as the rule and re-examines the mainline form.
310310

311-
### O3. A render effect gated away from a never-landing flight keeps the source's write held — violation, open
311+
### O3. A render effect gated away from a never-landing flight keeps the source's write held — fixed
312312

313-
**Status:** **violation, recorded** 2026-09-15 — fuzzer #3446 law P1 ("ordinary writes publish after a drain when no visible reader still needs an unresolved answer"), 21 of 1,000 cases in one symptom group, reduced to case 854; reproduced in the posture matrix (`effect × gatedAway` on the "observed only by the matrix reader" state) and pinned `it.fails` in `tests/posture-born-held-and-observation.test.ts`.
313+
**Status:** **violation, fixed** 2026-09-16 — fuzzer #3446 law P1 ("ordinary writes publish after a drain when no visible reader still needs an unresolved answer"), 21 of 1,000 cases in one symptom group, reduced to case 854; reproduced in the posture matrix (`effect × gatedAway` on the "observed only by the matrix reader" state) and pinned in `tests/posture-born-held-and-observation.test.ts`.
314314
**Current behavior:** a render effect that directly observed an uninitialized async memo registers as the flight's reporter (`_asyncReporters`); when it re-runs without reading the memo (a `show()` gate closes) the source's ordinary write stays held — forever when the flight never lands. A memo between the effect and the flight releases the hold (its re-run clears its status). `reporterBlocksSource` still answers true for the effect from its stale `_pendingSources` / NotReady `source`, and the parked transaction's verdict may not be re-evaluated by a flush with no async event.
315-
**Rule:** A15 / #3426 — the hold lasts while a LIVE reporter observes the flight; "re-ran and no longer derives from the source" is the fifth liveness case after disposed, zombie, behind-fallback and first-observer. The fix belongs in one `readerLive()` predicate, not a fifth arm.
315+
**Rule:** A15 / #3426 — the hold lasts while a LIVE reporter observes the flight; "re-ran and no longer derives from the source" is the fifth liveness case after disposed, zombie, behind-fallback and first-observer.
316+
**Mechanism (2026-09-16):** the predicate was already right — `reporterBlocksSource` judged the re-run effect dead; nothing RE-JUDGED the parked transaction. `recompute`'s tail now treats a pending reporter recovering without its flight landing as the completion event it is: it wakes the transaction it reported to (`wokenTransitions`, the third site after disposal #3372 and boundary reset #3375; `wakeParked` when the reporter carries no stamp), skipped under that transaction's own flush, which judges the landing itself. 21 → 4 of 1,000 fuzzer cases.
317+
**Remaining form (open):** gate and write in ONE flush (fuzzer case 21; case 79 is the multi-step variant). The effect is notified pending by the write — registering as the reporter — and dirtied by the gate in the same flush; the verdict runs after the pure phase, before effects, so the effect still looks live, the transaction parks, and the effect's run (which would prove it dead) is stashed with the transaction. The hold keeps the run that would release it; disposal releases (#3372). Pinned `it.fails`. Belongs with the effect-phase parking question (#3407: which world an effect's run belongs to when a mainline write and a held flight dirty it in one flush).
316318

317319
## Superseded rules (kept verbatim)
318320

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import {
9999
queuePendingNode,
100100
runInTransition,
101101
schedule,
102+
wokenTransitions,
102103
zombieQueue
103104
} from "./scheduler.js";
104105
import type {
@@ -276,8 +277,8 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
276277
// A conditional can drop its pending source and recover to an unchanged
277278
// value, leaving blocked dependents outside that source’s settle walk.
278279
const outgoingError = el._statusFlags & STATUS_ERROR ? el._x?._error : undefined;
279-
const outgoingPendingSources =
280-
el._statusFlags & STATUS_PENDING ? el._x?._pendingSources : undefined;
280+
const wasPending = (el._statusFlags & STATUS_PENDING) !== 0;
281+
const outgoingPendingSources = wasPending ? el._x?._pendingSources : undefined;
281282
// Pending SOURCE-hood, captured before the compute clears status: a node
282283
// whose own flight parked dependents self-registers in _pendingSources
283284
// (notifyStatus, isSource). If this recompute supersedes that flight and
@@ -679,6 +680,22 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
679680
if (wasPendingSource && !(el._statusFlags & (STATUS_PENDING | STATUS_UNINITIALIZED)))
680681
settlePendingSource(el);
681682
}
683+
// A pending REPORTER that recovered without its flight landing — this pass
684+
// no longer reads the source (a gate closed) — stops counting for the
685+
// transaction it reported to (A15 / #3426: the hold lasts while a live
686+
// reporter observes the flight). Nothing else re-judges a parked
687+
// transaction (see wokenTransitions; the disposal (#3372) and boundary
688+
// (#3375) twins of this site), so the writes it held stayed staged for as
689+
// long as the flight stayed up — forever, for one that never lands
690+
// (fuzzer #3446 P1, spec O3). Not under the transaction's own flush: the
691+
// landing that recovers a reader there is judged by that flush.
692+
if (isEffect && wasPending && !(el._statusFlags & STATUS_PENDING)) {
693+
const t = el._transition;
694+
if (t !== null && t !== activeTransition && !t._done && !wokenTransitions.includes(t)) {
695+
wokenTransitions.push(t);
696+
schedule();
697+
}
698+
}
682699
// Dependencies are the committed frame's until it is replaced (A30, #3410; the
683700
// deps twin of the held children above): a pass that staged its value
684701
// leaves the previous pass's tail linked for `commitPendingNode` to trim,

‎packages/signals/tests/posture-born-held-and-observation.test.ts‎

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -122,43 +122,73 @@ describe("B — creation under a transaction escapes the hold (OBSERVED, spec O2
122122
});
123123
});
124124

125-
describe("P1 — a reader that stopped reading the flight must not keep its hold (fuzzer #3446 P1; A15 / #3426 live reporter) — VIOLATION, pinned it.fails", () => {
125+
describe("P1 — a reader that stopped reading the flight does not keep its hold (fuzzer #3446 P1; A15 / #3426 live reporter)", () => {
126126
// Reduced from fuzzer case 854 (seed 3289) and the posture matrix's
127127
// `effect × gatedAway` cell on the "observed only by the matrix reader"
128128
// state. A render effect DIRECTLY observing an uninitialized async memo
129129
// registers as the flight's reporter; when it re-runs without reading the
130130
// memo (gate closed) nothing visible needs the unresolved answer, yet the
131131
// source's ordinary write stays held — forever, since the flight never
132-
// lands. With a memo between the effect and the flight the hold releases
133-
// (the memo's re-run clears its status); the effect's own stale
134-
// `_pendingSources` / NotReady source keeps `reporterBlocksSource` true.
135-
it.fails(
136-
"gating a render effect away from a never-landing memo releases the source's write",
137-
async () => {
138-
const [s, setS] = createSignal(0);
139-
const [show, setShow] = createSignal(true);
140-
const published: unknown[] = [];
141-
createRoot(() => {
142-
const m = createMemo(() => {
143-
s();
144-
return new Promise<number>(() => {}); // never lands
145-
});
146-
createRenderEffect(
147-
() => (show() ? m() : "hidden"),
148-
v => {
149-
published.push(v);
150-
}
151-
);
132+
// lands. The predicate (`reporterBlocksSource`) already judged the effect
133+
// dead after its re-run; nothing RE-JUDGED the parked transaction — the
134+
// flush that re-ran the effect had no active transaction. Fixed at
135+
// recompute's tail: a pending reporter that recovers without its flight
136+
// landing wakes the transaction it reported to (wokenTransitions — the
137+
// third site after disposal #3372 and boundary reset #3375).
138+
it("gating a render effect away from a never-landing memo releases the source's write", async () => {
139+
const [s, setS] = createSignal(0);
140+
const [show, setShow] = createSignal(true);
141+
const published: unknown[] = [];
142+
createRoot(() => {
143+
const m = createMemo(() => {
144+
s();
145+
return new Promise<number>(() => {}); // never lands
152146
});
153-
flush();
154-
setS(1);
155-
flush();
156-
expect(s()).toBe(0); // held by the observed flight — correct
157-
setShow(false);
158-
flush();
159-
await tick();
160-
expect(published).toEqual(["hidden"]); // the reader re-ran and no longer derives from m
161-
expect(s()).toBe(1); // P1: nothing visible still needs the answer — publish
162-
}
163-
);
147+
createRenderEffect(
148+
() => (show() ? m() : "hidden"),
149+
v => {
150+
published.push(v);
151+
}
152+
);
153+
});
154+
flush();
155+
setS(1);
156+
flush();
157+
expect(s()).toBe(0); // held by the observed flight — correct
158+
setShow(false);
159+
flush();
160+
await tick();
161+
expect(published).toEqual(["hidden"]); // the reader re-ran and no longer derives from m
162+
expect(s()).toBe(1); // P1: nothing visible still needs the answer — publish
163+
});
164+
});
165+
166+
describe("P1, same-flush form — gate and write in ONE flush (fuzzer #3446 case 21) — VIOLATION, pinned it.fails", () => {
167+
// The effect is notified pending by the write (registering as the flight's
168+
// reporter) and dirtied by the gate in the same flush. The verdict runs
169+
// after the pure phase, BEFORE effects: the effect still looks live, the
170+
// transaction parks, and the effect's run — the one that would prove it
171+
// dead (it no longer reads the memo) — is stashed WITH the transaction.
172+
// The hold keeps the run that would release it. Disposing the reader
173+
// releases (#3372). Spec O3, remaining form.
174+
it.fails("closing the gate and writing the source in one flush releases the write", async () => {
175+
const [s, setS] = createSignal(0);
176+
const [show, setShow] = createSignal(true);
177+
createRoot(() => {
178+
const m = createMemo(() => {
179+
s();
180+
return new Promise<number>(() => {});
181+
});
182+
createRenderEffect(
183+
() => (show() ? m() : "hidden"),
184+
() => {}
185+
);
186+
});
187+
flush();
188+
setShow(false);
189+
setS(1);
190+
flush();
191+
await tick();
192+
expect(s()).toBe(1);
193+
});
164194
});

‎packages/signals/tests/treeshake.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ describe("pay-for-use tree-shaking (#2883)", () => {
321321
// (`unflushedStaged`) instead of `_running`: inline, they cost ~140 B of
322322
// setSignal bytecode and 10–20% on the write-loop benches (+156 B here).
323323
// Measured at 24,478 rebased over #3464–#3471 (`next` 23,750 → 24,478).
324-
expect(minifiedBytes).toBeLessThan(24_600);
324+
// A pending reporter recovering without its flight landing wakes its
325+
// parked transaction (fuzzer #3446 P1, spec O3, 2026-09-16): +100 B
326+
// (24,478 -> 24,578), `wasPending` and the wokenTransitions site at
327+
// recompute's tail.
328+
expect(minifiedBytes).toBeLessThan(24_700);
325329
});
326330

327331
it("plain stores shed the verdict layer, affects, boundaries, and map", async () => {

‎scripts/size/.size-limit.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@ module.exports = [
498498
// merged.
499499
// A28 — writes visible at flush, read-side (2026-09-15): measured at 16,155 B
500500
// against `next` (+305 B); the signals core delta, see the core floor note.
501-
limit: "16.20 KB",
501+
// A pending reporter recovering without its flight landing wakes its parked
502+
// transaction (fuzzer #3446 P1, spec O3, 2026-09-16): measured at 16,201 B
503+
// (+1 over the cap); +100 B minified in the signals floor (24,478 -> 24,578).
504+
limit: "16.25 KB",
502505
modifyEsbuildConfig
503506
},
504507
{

0 commit comments

Comments
 (0)