Skip to content

fix(signals): keep foreign-refresh derivations standing in across store reads - #5273

Open
semanym wants to merge 1 commit into
solidjs:mainfrom
semanym:fix/optimistic-store-move-show-empty
Open

semanym wants to merge 1 commit into
solidjs:mainfrom
semanym:fix/optimistic-store-move-show-empty

Conversation

@semanym

@semanym semanym commented Nov 29, 2026

Copy link
Copy Markdown

Summary

Fixes #5202.

  • Root cause: In packages/signals/src/store/thinOptimistic.ts, when a non-render-effect derivation reads an optimistic store while a live guess stands in for a foreign action's refresh() (D-34, F-11), the first trap read links the derive node as a stale reader (link(d, c) / staleReader) and returns standing code 3. On subsequent reads of the same store within the same pass (e.g. Array.prototype.findIndex reading length and elements), the linkedTo(c, d) guard only recognized code 2 from the #4561 path (heldC === c && heldAt === clock) and fell through to read(d). For an uninitialized derivation (such as a newly mounted <For> row's createMemo), read(d) threw NotReadyError, holding the row's <Show> subtree so the moved row rendered empty.
  • Fix:
    • Track per-family (computation, _depGen, standingCode) tags in a lazy WeakMap on fam.h so both code 2 and code 3 stay standing in across subsequent trap reads in the same pass (re-entrantly across nested memos and independently across multiple stores) and re-link across subsequent passes while the refresh remains foreign (D-34, F-11).
    • In packages/signals/src/store/thin.ts, scope standing by _depGen, unwrap internal Root owners (_parentComputed) when recording standing, and apply the same CONFIG_HELD (non-override) committed-value check in untracked peek() as in frameRead() so tracked length reads and untracked slot reads (such as mapArray's updateKeyedRows) stay consistent on one frame (F-1).
    • Sync packages/signals/docs/RULES-INDEX.md, add .changeset/optimistic-store-foreign-refresh-standing.md, and add unit and DOM regression tests.

No public API changes.

How did you test this change?

🤖 Generated with Claude Code

…re reads

When a derivation reads a keyed optimistic store while a live guess
stands in for another action's `refresh()`, the first trap access links
the derive node as a stale reader (`link(d, c)` / `staleReader`) and
returns standing code 3 (D-34, F-11). On subsequent reads of the same
store in the same pass (such as `Array.prototype.findIndex` reading
`length` and elements), the `linkedTo(c, d)` guard only recognized code
2 from the `solidjs#4561` path and fell through to `read(d)`, throwing
`NotReadyError` on uninitialized memos (e.g. a per-row `createMemo`
mounted under `<For>` / `<Show>`) and leaving the row empty.

Track per-family `(computation, depGen, standingCode)` tags on `fam.h`
so both code 2 and code 3 reads stay standing in across subsequent trap
reads in the same pass (re-entrantly across nested memos) and across
re-runs while the foreign refresh remains foreign. Also scope `standing`
in `thin.ts` by `_depGen` and apply it in untracked `peek()` (unwrapping
internal `Root` owners such as `mapArray`'s row lookup so tracked
length reads and untracked slot reads stay consistent on a single frame
(F-1).

Fixes solidjs#5202

Co-Authored-By: Claude Code <noreply@anthropic.com>
EOF
)
@changeset-bot

changeset-bot Bot commented Nov 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 04a71b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@solidjs/signals Patch
@solidjs/web Patch
@solidjs/diagnostics Patch
solid-js Patch
@solidjs/universal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[signals] A row moved into another keyed createOptimisticStore renders empty under Show when a per-row memo reads the store

1 participant