Repository navigation
Conversation
…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 detectedLatest commit: 04a71b7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5202.
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'srefresh()(D-34, F-11), the first trap read links the derive node as a stale reader (link(d, c)/staleReader) and returns standing code3. On subsequent reads of the same store within the same pass (e.g.Array.prototype.findIndexreadinglengthand elements), thelinkedTo(c, d)guard only recognized code2from the#4561path (heldC === c && heldAt === clock) and fell through toread(d). For an uninitialized derivation (such as a newly mounted<For>row'screateMemo),read(d)threwNotReadyError, holding the row's<Show>subtree so the moved row rendered empty.(computation, _depGen, standingCode)tags in a lazyWeakMaponfam.hso both code2and code3stay 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).packages/signals/src/store/thin.ts, scopestandingby_depGen, unwrap internalRootowners (_parentComputed) when recordingstanding, and apply the sameCONFIG_HELD(non-override) committed-value check in untrackedpeek()as inframeRead()so tracked length reads and untracked slot reads (such asmapArray'supdateKeyedRows) stay consistent on one frame (F-1).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?
origin/main(both with the outer<Show>where the moved row rendered empty, and without the outer<Show>moving to index0where the inner<Show>droppedv).packages/signals/tests/optimistic-store-move-show-5202.test.ts(multi-readfindIndexon newly mounted rows, subsequent re-runs while foreign refreshes remain in flight, nested memos reading the same store, and full settle).packages/web/test/optimistic-store-move-show-5202.spec.tsx(original [signals] A row moved into another keyed createOptimisticStore renders empty under Show when a per-row memo reads the store #5202 repro + reorder + full settle, and the no-outer-Showindex-0 case).node packages/signals/scripts/rules-index.mjs --check— passedpnpm build— 30/30 tasks passedpnpm test(all package test suites, type tests, and typecheck) — 39/39 tasks passednode scripts/size/size.mjs --no-gate --json ... && node scripts/size/gate.mjs ...— all scenarios passprettier --checkon all modified files — passed🤖 Generated with Claude Code