Skip to content

Commit ad973ed

Browse files
ryansolidclaudebrenelz
authored
fix(signals): carve async toward the F/D rules; redo #3937, #3954, #3895 (#3977)
* fix(signals): a first load born under a hold holds it (column 2); drop _bornIn A new async memo whose first pass reads a held value is held at creation, like its sync twin (A29): its answer is the hold's, and the hold waits for it. A fresh or re-armed boundary that catches the pass keeps it (#3540): then the hold does not wait. This replaces #3881's _bornIn, which landed the first answer into a live hold but never let the hold wait for it (the direction rule's time half, withdrawn 2026-10-09). - issue-3800-repro: a slower first load keeps the hold open; the action's hold waits for the pages read outside a boundary. - direction-rule-probe: the three same-tick/in-flush shapes are no longer `it.fails` — they assert the wait. Size (local, Rolldown): minified -22..-24 B on every scenario; core floor 7440 -> 7431 B br, hello world 9935 -> 9927 B br. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): a probe alone does not hold A verdict read (`isPending`, `latest`) registers its reader to re-derive at the landing — the verdict flips there — without making it a holder of the hold. A render effect holds when its read threw, or when, beside a probe, its plain read of the flight was served the committed value (REACTIVE_FRAME_READ, the stale reader; #3442 / A10). #3774 routed the probe's re-run through the stale reader, which also made it a blocker, against its own stated intent ("a probe alone is neither"). Fixes a probe-only header keeping a same-source `Loading on` re-arm's fallback off screen (the header's probe held `data`, so the content under the boundary was served the committed value instead of throwing). Re-pinned (only probes read the async, so nothing holds): - optimistic-settle-verdicts #3409: after the revert each indicator clears with its own flight (7000 / 8000), as in the optimistic phase. - question-scoped-pending 3.4: the list is now rendered plainly, as a <For> would; that reader is what keeps the hold and the action's mark alive through the refetch. Size (local): +20 B minified on core / hello world, brotli -3 / -27 B. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): a boundary that has not shown content catches a held reader A fresh <Loading> (never initialized) keeps a reader held by an outside transaction on its fallback instead of joining it to the hold (#3540 re-arm shapes, 'content bound' rows now pass). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): the reader's position decides a born-held memo's catch A memo's first pass that reads a hold is born held without joining the tick: a render effect that reads it decides. Under a boundary that has not shown content the boundary catches that render effect at its staging (the pass's own status clear dropped the read-time record), so the fallback shows now and the content at the commit. Outside one, the tick joins the hold as before. A memo nobody renders holds nothing (#3802 re-pinned: the mount runs on committed values, never without one). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): isPending of a memo born held reads as its read A memo born held has no committed value, so no verdict (D-23): inside an owner, isPending of it joins the hold as a plain read of it does — held with the change, or caught by a boundary that has not shown content — and answers for the commit, where it is final. Unowned it is false. latest() of it is still its pending value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * perf(signals): one live-transaction check per seam; share the owned check The seam resolved its transaction's liveness twice (ambient marks, then the park decision): once now. verdictValue computes the owned-reader test once for the tracked arm and the born-held join. core floor 20359 -> 20330 B minified, hello world 27868 -> 27839, isPending/latest 27508 -> 27465. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): judge an optimistic row's echo as reconcile would, not by JSON (#3898) Redoes #3937's content check. The server's echo of a guessed store row is a new object, so reference equality makes every echo a correction (and a mainline until() then waits on the hold, D-31). The guess is confirmed when reconcile would write nothing into it from the truth: wrappable pairs descend, leaves compare as its writes do. JSON.stringify differed on key order, undefined, Dates and cycles; this is key-order free. The check lives in the optimistic store (GlobalQueue._echoes), so lanes without stores no longer carry it. isPending/latest 27465 -> 27338 B minified (9747 -> 9716 brotli); every store family 29114 -> 29105 brotli. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): an errored reader is not re-derived at a landing (#3945) Redoes #3954. A row binding that reads a derived-store field and isPending is a verdict reader; the landing of the refetch's transaction re-derived it (reruns), and that later-cycle tracked read retried the errored store: an unrequested refetch, unbounded if it kept failing. An errored reader's display is its error (D-39): reruns skip it. #3954's sticky _errorMeet mark on subscribers is removed; it also stopped a genuine re-read (the reader's own input changing) from retrying, which a new test pins. core floor +7 B minified, createStore -11. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * refactor(signals): refresh()'s waiter reads authoritatively (#3895) Redoes #3895's waiter. It read the guessed node's staged truth by hand; the waiter is now an authoritative reader (until()'s view: the truth beneath a guess), and keeps only the part refresh adds — a guessed node's own re-ask parks the waiter, or rejects it with its error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * test(signals): a verdict beside a plain read shows now in either read order Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * test(signals): pin #3962 and #3957, fixed by this branch #3962 fails on next (the #3954 mark) and passes here; #3957's rejection reaches Errored with or without a separate isPending reader. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * fix(signals): pass a lane node's committed value as prev (#3955) A derivation that reads `latest()` or `isPending()` of a signal an in-flight async memo is holding enters the verdict lane with `_x._lane` still `NOT_PENDING`. When that first lane pass is equal to the previous value, nothing writes the slot, so the next pass under the hold received the `NOT_PENDING` marker as `prev` and a `createSignal((prev = []) => [...prev])` threw `prev is not iterable`, halting the reactive system. The pass now falls back to the committed value when the slot is empty, as `compareValue` already does. * fix: address review findings The comment above the pass's previous value in `recompute` now says a lane node's lane value is used only when the slot holds one, matching the guarded expression beneath it. The #3955 test now covers `createMemo(fn)` beside `createSignal(fn)`, asserts that the landing after the equal lane passes flushes without throwing and records only arrays, and resets a halted system after each case so each case fails on its own pre-fix. The changeset describes the thrown `prev is not iterable` instead of the internal marker. * fix(signals): review fixes for #3977 - echoes(): a self-referencing row is a correction, not a stack overflow (next's JSON.stringify threw and fell back the same way); pinned. - Changeset for the branch's behaviour changes. - Dead lines removed from fresh-boundary-born-held-reader.test.ts. - it.fails pin: an async memo created inside a fresh boundary over a held value shows its answer before the hold commits (D-12; creation position still decides in that shape). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * test(signals): an optimistic signal's echo is judged by its equals Ruling 2026-10-11: signals don't reconcile, they equality-check — a server's new array corrects unless the signal's equals says otherwise. Pinned both ways; changeset notes the change from next's JSON compare. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * test(web): an isPending guard on a born-held memo never shows enabled early <input disabled={isPending(data)}> over a memo born held: during the hold the branch is held (or on its fallback under a fresh Loading), so no enabled input over an unjudged value is ever seen; at the commit it shows disabled=false with the committed value (D-23). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LVm3wseHt9wRTY8LfPiHmQ * test(web): drop a redundant shape comparison that failed test-types Inside the non-direct branch `shape` is already narrowed to "show" | "show+loading", so `shape !== "direct"` was TS2367 and failed @solidjs/web#test-types in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017PDt8Jv6uf5xRDsrux4UwF --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Brenley Dueck <[email protected]>
1 parent a497d4b commit ad973ed

29 files changed

Lines changed: 928 additions & 145 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Async holds follow the reader, and are shorter:
6+
7+
- A first load read by a render effect outside a `<Loading>` makes the change that mounted it wait (the async answer of a memo created under a hold lands with that hold); a `<Loading>` that has not shown content catches it instead and shows its fallback.
8+
- Creating a memo no longer pulls the whole tick into a hold: the render effect that reads it decides. A memo nobody renders holds nothing.
9+
- `isPending` or `latest` alone never holds a change; a plain read beside them still does.
10+
- `isPending` of a memo born held joins the hold with its reader instead of reporting a verdict.
11+
- An optimistic store row's server echo is judged as reconcile would (key order free, a self-referencing row is a correction) instead of by `JSON.stringify`.
12+
- An errored reader is not re-run when a transaction lands, so an errored derived store is not refetched by a row that also reads `isPending` (#3945, #3962).
13+
- `refresh()`'s promise reads the truth beneath a guess the same way `until()` does (#3895).
14+
- An optimistic **signal** (`createOptimistic`) judges its source's answer with its own `equals`, as signals do: a server's new array or object is a correction unless `equals` says it is the same. (`next` compared every optimistic answer with `JSON.stringify`.) Store rows follow reconcile: equal `Date` objects, or `{ t: undefined }` against a missing key, are corrections.
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 `createSignal(fn)` or `createMemo(fn)` derivation that reads `latest()` or `isPending()` of a signal an in-flight async memo is holding receives its previous value as `prev` on every re-run under the hold. When its first pass under the hold was equal to the previous value, the next pass received an empty internal marker instead, so `(prev = []) => [...prev]` threw `prev is not iterable` and halted the reactive system.

‎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:111` | — | 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:301` | — | 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:95` | 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:119` | 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 … |
76+
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:119` | boundaries.ts×1 action.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:257` | 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:131` | 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:139` | 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/boundaries.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,11 @@ export function prune(b: Boundary, pass: boolean): number {
301301
// Landed, held: the content is that transaction's — the output's
302302
// pass enters it and the reveal lands with the reader's run. The
303303
// seam, past its park decision, waits for the commit instead. (A
304-
// lane's reader reveals with the lane, this round.)
305-
if (!pass) continue;
304+
// lane's reader reveals with the lane, this round.) A boundary that
305+
// has not shown content catches it instead: the fallback stays until
306+
// the reader is committed (#3540: what a fresh boundary catches holds
307+
// nothing outside it).
308+
if (!pass || !b._initialized) continue;
306309
joinFuture(txOf(r));
307310
}
308311
b._readers.delete(r);

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import {
2929
flush,
3030
globalQueue,
3131
GlobalQueue,
32-
holdNode,
3332
joinFuture,
34-
liveTx,
3533
MAINLINE_QUESTION,
3634
passLane,
3735
question,
@@ -476,11 +474,8 @@ export function handleAsync<T>(
476474
} else {
477475
// CARVE 2: the override-covered landing (hold + A18 supersession) and the
478476
// lane-routed landing (derived override, lane effect queue) went with
479-
// the optimistic engine; every landing is the plain setSignal. A first
480-
// answer born into a hold still live lands into it (A29, #3800).
481-
let t = el._x!._bornIn;
482-
el._x!._bornIn = null;
483-
if (wasUninitialized && t && (t = liveTx(t))) holdNode(el, t);
477+
// the optimistic engine; every landing is the plain setSignal. A node
478+
// already held stages its answer into that hold (`setSignal`).
484479
try {
485480
setSignal(el, () => value);
486481
} catch (e) {

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,12 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
374374
// — here, the finally below, updateIfNecessary — carries it (#3543).
375375
el._flags = REACTIVE_RECOMPUTING_DEPS | (el._flags & REACTIVE_ZOMBIE);
376376
el._time = clock;
377-
// The pass's previous value: its staging, else the lane's value for a
378-
// lane's node (lanes.ts), else the committed one.
377+
// The pass's previous value: its staging, else a lane node's lane value
378+
// when it has one (lanes.ts), else the committed one.
379379
let value =
380380
el._pendingValue !== NOT_PENDING
381381
? el._pendingValue
382-
: el._config & CONFIG_OVERRIDE
382+
: el._config & CONFIG_OVERRIDE && el._x!._lane !== NOT_PENDING
383383
? el._x!._lane
384384
: el._value;
385385
let oldHeight = el._height;
@@ -678,6 +678,10 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
678678
// derives from the future (`read`), an untracked one throws
679679
// (A19 exc. 1).
680680
el._statusFlags |= STATUS_UNINITIALIZED;
681+
// A boundary that has not shown content catches it: its fallback
682+
// waits for the commit (#3540). (The pass's own status clear above
683+
// dropped what the read recorded.)
684+
GlobalQueue._fresh?.(el);
681685
}
682686
if (__DEV__) devTrackHeldPending(el);
683687
}
@@ -715,16 +719,18 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
715719
}
716720
// A first pass that went pending where the born-held arm would have held
717721
// its value (it read a held node, or a verdict lane's mount read a staging,
718-
// #3851) is born into that transaction without holding it: the hold never
719-
// waits for a first load (the direction rule), but the answer lands into it
720-
// while it is live (A29, #3800).
722+
// #3851) is held like it: its answer is the hold's, and the hold waits
723+
// for it (A29, #3800) — unless a boundary that has not shown content
724+
// catches it: then it is the boundary's, and the hold does not wait (#3540).
721725
if (
722726
create &&
723727
lane === null &&
724728
(joined || (prevLane && el._flags & REACTIVE_STAGED_READ)) &&
725729
el._statusFlags & STATUS_PENDING
726-
)
727-
ext(el)._bornIn = flushTransaction ?? passTx;
730+
) {
731+
const t = flushTransaction ?? passTx;
732+
if (t !== null && !t._lane && !GlobalQueue._fresh?.(el)) holdNode(el, t);
733+
}
728734
// Dependencies are the committed frame's until it is replaced (A30, #3410):
729735
// a pass that staged its value leaves the previous pass's tail linked for
730736
// `commitPendingNode` to trim, so a write to a dependency the committed
@@ -962,7 +968,6 @@ export function ext(el: { _x: NodeExtension | null }): NodeExtension {
962968
_pendingFirstChild: null,
963969
_pendingDisposal: null,
964970
_transaction: null,
965-
_bornIn: null,
966971
_reask: false,
967972
_flushed: NOT_PENDING,
968973
_flushedAt: -1,
@@ -983,13 +988,21 @@ export function ext(el: { _x: NodeExtension | null }): NodeExtension {
983988
* something not ready under a loading boundary that has not shown content:
984989
* the boundary collects it and shows its fallback, and the pass is the
985990
* boundary's, not the tick's (A29's boundary exemption, #3540). */
986-
function joinPass(c: Computed<any>, el: Signal<any> | Computed<any>): void {
991+
export function joinPass(c: Computed<any>, el: Signal<any> | Computed<any>): void {
987992
c._flags |= REACTIVE_JOINED;
993+
// A new memo's first pass is the hold's work (born held) but not the
994+
// tick's: a render effect that reads it decides — under a boundary that
995+
// catches it, the boundary's; otherwise the tick joins the hold (#3540:
996+
// the reader's position, not where the memo was created). Its catch, if
997+
// any, is at its staging.
988998
if (
989999
(el as Computed<any>)._statusFlags & STATUS_UNINITIALIZED ||
9901000
(c as any)._type !== EFFECT_RENDER
9911001
)
992-
joinPassTx(txOf(el), GlobalQueue._fresh?.(c));
1002+
joinPassTx(
1003+
txOf(el),
1004+
(!(c as any)._type && c._statusFlags & STATUS_UNINITIALIZED) || GlobalQueue._fresh?.(c)
1005+
);
9931006
}
9941007

9951008
/** A15's stale reader (shared-hole and reveal corollaries): a render effect

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -378,33 +378,17 @@ export function laneStage(
378378
* covered (no landing beneath it) — `optimisticReverted`'s "reverted". */
379379
let reverting = false;
380380

381-
/** Plain data with the same contents: an optimistic row and the source
382-
* object that echoes it. Not reference equality. A throw (a cycle, a
383-
* throwing accessor) is not a match, so that landing stays a correction. */
384-
function sameContents(a: unknown, b: unknown): boolean {
385-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) return false;
386-
try {
387-
return JSON.stringify(a) === JSON.stringify(b);
388-
} catch {
389-
return false;
390-
}
391-
}
392-
393381
export function supersede(n: Signal<any> | Computed<any>, value: unknown, changed: boolean): void {
394382
const l = txOf(n);
395383
// Resolved: the parent may have merged into another transaction since the
396384
// lane opened (two actions guessing one slot entangle, A34 (1)) — the
397385
// truth is held by the transaction that lands, not the merged-away one.
398386
const parent = resolveTx(l._parent ?? l);
399-
// A different object with the same plain contents is the guess's echo, not
400-
// a correction (#3898). Reference inequality dissolved the lane and held
401-
// the echo under the open action, so a mainline `until` (after `await`)
402-
// dropped a source that already contained the acknowledgement. Confirming
403-
// stages the truth beneath the guess: the screen keeps the guess, and an
404-
// authoritative reader sees the echo without the pass joining the hold.
405-
// A real content change still corrects. A held broadcast of a different row
406-
// (#3482) is not this landing.
407-
if (changed && sameContents(n._x!._lane, value)) changed = false;
387+
// A store row answered by a new object the store would reconcile into
388+
// the guessed one unchanged is an echo, not a correction (#3898): the
389+
// server's object never matches the guess by reference.
390+
if (changed && n._config & CONFIG_SLOT_NODE && GlobalQueue._echoes?.(n._x!._lane, value))
391+
changed = false;
408392
if (changed) {
409393
// Observe: a displayed guess is being replaced by a differing truth — a
410394
// landing's (superseded), or the value it covered (reverted: the body

0 commit comments

Comments
 (0)