Skip to content

fix(signals): an optimistic reorder of keyless rows reaches <For> (#4344) - #4358

Closed
ryansolid wants to merge 1 commit into
nextfrom
claude/project-thread-x1ore2-4344
Closed

ryansolid wants to merge 1 commit into
nextfrom
claude/project-thread-x1ore2-4344

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Fixes #4344

Summary

Before: an action does setItems(() => [row("c"), row("b"), row("a")]) on a createOptimisticStore whose rows have no id. While it is pending, direct reads give c,b,a, but <For> (keyed and non-keyed) keeps rendering a,b,c. With an id on the rows, <For> shows c,b,a. This regressed in 1c14992 (#3898 / #3937).

Cause: a returned array is written by index. notifyOptimisticWrites puts a guess on each index node, which direct reads see. It also puts an arrangement guess (LaneView) on the container node, which is the node <For>/mapArray reads. optimisticWrite drops a guess that the node's comparator calls equal to what the user saw. The container's comparator (arrangement → arrangementEqual → rowSame) has counted two keyless rows at the same index as the same row since #3937. So the reorder was judged "no change of arrangement", the container guess never reached the seam, and <For> never re-ran. The same rule also kept the screen from hearing the revert at the settle.

After: a keyless row has only its contents. At the same index it is the same row when the store would reconcile it unchanged (GlobalQueue._echoes, the cycle-safe check #3898's landing already uses). Otherwise it is a different row. A server echo of a keyless guess still confirms the arrangement (#3898). A reorder or a replaced row now changes the container, so direct reads and <For> agree both at the guess (F-11: the guess shows at once) and after the settle (D-33: nothing wrote the truth, so the guess reverts). Keyed rows are unchanged: they still match on the key.

One line of logic in rowSame, with no new exports, computations or effects.

How did you test this change?

  • New packages/signals/tests/optimistic-reorder-keyless-4344.test.ts. It covers plain and derived stores, rows with and without id, keyed and non-keyed mapArray, a returned reorder, and a swap written in the draft. It checks the exact list output at the guess, one tick later, and after the settle (revert to a,b,c). For the derived store it also checks the action writing the truth, which lands c,b,a. The 10 keyless cases fail on next and pass here.
  • New packages/web/test/optimistic-reorder-keyless-for-4344.spec.tsx. This is the issue's repro with exact innerHTML checks at the guess, one tick later, and after the settle, for <For> keyed and keyed={false}, with and without id. Both keyless cases fail on next and pass here.
  • Full suites: signals 357 files / 5670 tests pass. solid 52 / 897 pass. web client, server and hydrate suites: the only failures also fail on next in this environment (uncommitted-input-overwritten, server-functions-adapter-request "keeps a rebuild failure's own error…", lone-spread-hydration-key-4240 with a locally stale native compiler, c03-hydration-done-counts-holds). served-error-no-reask "[streamed] the content waits for its sheet" failed once under load and passed on rerun.
  • tsc -p tsconfig.build.json in signals: clean.
  • scripts/size: only app: hydrating + every store primitive family changes, by +9 B minified (95,467 → 95,476; recorded capMinified 95,467, so within the 20 B allowance) and +26 B brotli locally. No cap or floor moves.

Generated by Claude Code

)

A setter's returned array is written by index. On rows without a key, the
container's arrangement guess was judged equal to the committed rows,
because two keyless rows at one index counted as the same row (#3898).
The guess was dropped before the seam, so `<For>` (which reads the
container) never re-ran, while direct reads saw the per-index guesses.

A keyless row has only its contents: at the same index it is the same row
when the store would reconcile it unchanged (the #3898 echo still
confirms), and another row otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a71cb5

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

This PR includes changesets to release 15 packages
Name Type
@solidjs/signals Patch
test-integration Patch
@solidjs/web Patch
@solidjs/babel-plugin Patch
@solidjs/compiler Patch
@solidjs/diagnostics Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
solid-js Patch
@solidjs/universal Patch
board-example Patch
canvas-example Patch
server-dbmon-example Patch
todos-server-example 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

@github-actions

Copy link
Copy Markdown

Size (brotli, eager entry chunk)

scenario head vs base minified vs base minified vs recorded cap lazy chunks (not counted)
signals: core floor (createSignal/Memo/Effect/Root/flush) 7.42 KB 0 B 0 B −119 B 7.44 KB ✅
signals: + createStore 14.92 KB 0 B 0 B −1359 B 15.04 KB ✅
signals: + isPending/latest 10.37 KB 0 B 0 B −13 B 10.38 KB ✅
signals: + until/refresh (truth readers, no optimism) 8.05 KB 0 B 0 B −123 B 8.05 KB ✅
app: render + one signal (the simple-app floor) 9.78 KB 0 B 0 B −179 B 9.75 KB ⚠️ over by 26 B, 199 B minified headroom
app: hydrating (no stores) with Show/For/Loading/Errored/lazy 18.61 KB 0 B 0 B −244 B 18.49 KB ⚠️ over by 116 B, 264 B minified headroom lazy-page.js 0.04 KB
app: hydrating + every store primitive family 31.14 KB −28 B (−0.1%) +9 B +9 B 31.19 KB ✅ lazy-page.js 0.04 KB
app: CSR with Show/For/Loading/Errored/lazy 13.38 KB 0 B 0 B −250 B 13.40 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier (same app on the observe artifacts) 15.11 KB 0 B 0 B −256 B 15.14 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier + attribution engine enabled 29.69 KB 0 B 0 B −254 B 29.70 KB ✅ lazy-page.js 0.04 KB
app: compiled floor (one template, one text hole, one delegated click) 9.97 KB 0 B 0 B −178 B 9.93 KB ⚠️ over by 38 B, 198 B minified headroom
app: compiled CSR (JSX todo app: spread/merge/omit, events, class/style, keyed For, Show, Loading + lazy, store) 26.15 KB 0 B 0 B −573 B 26.27 KB ✅ stats.js 0.18 KB
app: compiled hydrating (the same JSX todo app through hydrate(), compiled hydratable) 32.34 KB 0 B 0 B −504 B 32.25 KB ⚠️ over by 91 B, 524 B minified headroom stats.js 0.20 KB
frames: eager client consumer (frames client + transport, lazy codec) 11.75 KB 0 B 0 B 0 B 11.76 KB ✅
page: base server components (hydrating + dynamic + frames + sf reference) 33.59 KB 0 B 0 B −182 B 33.37 KB ⚠️ over by 222 B, 202 B minified headroom assets.js 0.78 KB, decode.js 7.09 KB, lazy-page.js 0.04 KB, regions.js 1.06 KB, trace.js 9.01 KB, wire.js 3.47 KB
page: live server components (base + live/GET + action + isPending/latest) 37.94 KB 0 B 0 B +6 B 37.75 KB ⚠️ over by 194 B, 14 B minified headroom assets.js 0.78 KB, decode.js 7.09 KB, lazy-page.js 0.04 KB, regions.js 1.06 KB, trace.js 8.98 KB, wire.js 3.47 KB
page: compiled base server components (the base page as JSX: templates with class/style/attributes/events, For/Show; no spread) 35.50 KB 0 B 0 B −170 B 35.43 KB ⚠️ over by 69 B, 190 B minified headroom assets.js 0.78 KB, decode.js 7.09 KB, regions.js 1.06 KB, sc-comments.js 0.20 KB, trace.js 8.95 KB, wire.js 3.47 KB
page: compiled live server components (the compiled base page + live/GET + action + isPending/latest) 41.81 KB 0 B 0 B +5 B 41.56 KB ⚠️ over by 246 B, 15 B minified headroom eager (counted): web.js 22.37 KB; assets.js 0.78 KB, decode.js 7.09 KB, regions.js 1.07 KB, sc-comments.js 0.19 KB, trace.js 9.03 KB, wire.js 3.47 KB
page: base + router (base page + @solidjs/router: createRouter, two routes, preload, useNavigate) 40.99 KB 0 B 0 B −181 B 40.81 KB ⚠️ over by 179 B, 201 B minified headroom assets.js 0.78 KB, decode.js 7.09 KB, lazy-page.js 0.04 KB, regions.js 1.06 KB, server.js 1.03 KB, serverForms.js 3.59 KB, trace.js 8.98 KB, wire.js 3.48 KB
page: live + router (live page + @solidjs/router: createRouter, two routes, preload, useNavigate) 47.40 KB 0 B 0 B −15 B 47.16 KB ⚠️ over by 239 B, 35 B minified headroom eager (counted): client.js 27.49 KB; assets.js 0.78 KB, decode.js 7.09 KB, lazy-page.js 0.04 KB, regions.js 1.08 KB, server.js 1.03 KB, serverForms.js 3.30 KB, trace.js 8.99 KB, wire.js 3.49 KB
server: floor (getRequestEvent + isServer) 1.27 KB 0 B 0 B −69 B 1.34 KB ✅
server: renderToString (the server-render floor) 22.79 KB 0 B 0 B 0 B 22.80 KB ✅

⚠️ Over the brotli cap within the minified allowance (passes)

  • app: render + one signal (the simple-app floor): over brotli cap by 26 B; minified 26,850 B vs 27,029 B recorded with the cap (−179 B) — 199 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • app: hydrating (no stores) with Show/For/Loading/Errored/lazy: over brotli cap by 116 B; minified 53,376 B vs 53,620 B recorded with the cap (−244 B) — 264 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • app: compiled floor (one template, one text hole, one delegated click): over brotli cap by 38 B; minified 27,382 B vs 27,560 B recorded with the cap (−178 B) — 198 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • app: compiled hydrating (the same JSX todo app through hydrate(), compiled hydratable): over brotli cap by 91 B; minified 100,540 B vs 101,044 B recorded with the cap (−504 B) — 524 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: base server components (hydrating + dynamic + frames + sf reference): over brotli cap by 222 B; minified 101,377 B vs 101,559 B recorded with the cap (−182 B) — 202 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: live server components (base + live/GET + action + isPending/latest): over brotli cap by 194 B; minified 115,223 B vs 115,217 B recorded with the cap (+6 B) — 14 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: compiled base server components (the base page as JSX: templates with class/style/attributes/events, For/Show; no spread): over brotli cap by 69 B; minified 107,748 B vs 107,918 B recorded with the cap (−170 B) — 190 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: compiled live server components (the compiled base page + live/GET + action + isPending/latest): over brotli cap by 246 B; minified 123,221 B vs 123,216 B recorded with the cap (+5 B) — 15 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: base + router (base page + @solidjs/router: createRouter, two routes, preload, useNavigate): over brotli cap by 179 B; minified 125,206 B vs 125,387 B recorded with the cap (−181 B) — 201 B of the 20 B minified allowance left; +0 B minified over this PR's base
  • page: live + router (live page + @solidjs/router: createRouter, two routes, preload, useNavigate): over brotli cap by 239 B; minified 140,465 B vs 140,480 B recorded with the cap (−15 B) — 35 B of the 20 B minified allowance left; +0 B minified over this PR's base

Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and its minified size is more than 20 B over the minified recorded with the cap; over the cap within that allowance is brotli layout noise and passes with a warning. Caps and their recorded minified in scripts/size/scenarios.js; the floor and page caps in floor-caps.json are frozen (lower only, or Size-Exception: in the PR body). npm run ratchet lowers caps per RC; it never raises one (scripts/size/README.md).

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 40674997604

Coverage remained the same at 78.727%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1357
Covered Lines: 1127
Line Coverage: 83.05%
Relevant Branches: 1078
Covered Branches: 790
Branch Coverage: 73.28%
Branches in Coverage %: Yes
Coverage Strength: 28.47 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Member Author

I'm closing this in favour of #4360. That PR fixes #4344 with a broader rowSame rule: rows already served by a target count as the same row only when their targets match. It also fixes two more stale-row cases (a draft swap of identical keyless rows, and a fresh row returned with the same id). It is 27 B smaller than next on the store scenario, where this PR was 9 B larger. Both PRs edit the same lines, and #4360 already includes this PR's tests.


Generated by Claude Code

@ryansolid ryansolid closed this Oct 28, 2026
@codspeed

codspeed Bot commented Oct 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 3 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 196 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing claude/project-thread-x1ore2-4344 (9a71cb5) with next (38e0c49)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@ryansolid
ryansolid deleted the claude/project-thread-x1ore2-4344 branch November 5, 2026 17:34
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.

3 participants