Skip to content

Commit 1dc0b45

Browse files
fix(signals): make mark-only pending value-transparent on the read path
An affects() mark's sentinel put derived nodes into STATUS_PENDING, and read() treated that like real in-flight async — suspending the reader — so an optimistic insert under a whole-store mark never rendered in a live mapArray/For for the duration of the action (#2886). A mark is a promise of change, not an absence of value: reads whose owner's pending sources are all affects sentinels now skip the suspension branch (gated off the mark-free hot path by activeAffectsMarks), so pendingness reaches readers exclusively through isPending verdicts while values keep flowing. Co-authored-by: Cursor <[email protected]>
1 parent 442ad9a commit 1dc0b45

6 files changed

Lines changed: 97 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 `affects(store)` hiding concurrent optimistic writes from live tracked readers (#2886). A mark's sentinel put derived nodes (like a `mapArray` over the marked store) into `STATUS_PENDING`, and the read path treated that like real in-flight async — suspending the reader — so an optimistic insert under a whole-store mark never rendered for the duration of the action. Mark-only pending is now value-transparent through derivation: reads whose owner's pending sources are all affects sentinels never suspend, so pendingness reaches readers exclusively through `isPending` verdicts while values keep flowing.

‎packages/solid-signals/INTERNALS-ASYNC-STATE.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,12 @@ Supporting machinery:
440440
(`_affectsFor` brand) — a mark releases AT settle, so self-blocking would
441441
deadlock. The marked node itself never carries `STATUS_PENDING` (marks
442442
are value-transparent at the source; its own verdict is the
443-
`_affectsCount` clause). Computeds that recompute mid-window shed the
443+
`_affectsCount` clause), and **mark-only pending is value-transparent
444+
through derivation too** (#2886): `read()` skips the suspension branch
445+
when the owner's pending sources are all sentinels (`onlyMarkPending`,
446+
gated by `activeAffectsMarks`), so a live tracked reader over mark-pended
447+
derived nodes — a `mapArray` over a marked store — keeps rendering fresh
448+
optimistic values instead of throwing. Computeds that recompute mid-window shed the
444449
sentinel via `clearStatus` and re-acquire it through the read path:
445450
`read()` records marked sources into the recompute's `affectsReads`
446451
accumulator (gated by the global `activeAffectsMarks` counter; probe

0 commit comments

Comments
 (0)