Skip to content

Commit 1614587

Browse files
committed
Merge next into #4663 (after #4658, #4656)
Regenerates RULES-INDEX.md, the only conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC
2 parents d0c1bf7 + 227a01d commit 1614587

22 files changed

Lines changed: 1431 additions & 93 deletions
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 an infinite flush loop when a memo over an optimistic store list (an "N left" count, a filter) read through a lane re-based over a parked refresh (#4643). Lane work re-based over a hold's answer no longer joins the flush into that hold, so a plain write beside it (a filter change) shows once instead of showing, retracting and showing again, and a guess beside the held answer no longer reveals it early. A push after a removal guess no longer leaves an `undefined` row in the list.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Optimistic keyed lists: a push after a filter (with earlier saves still out) no longer hands `<For>` an `undefined` row; a guess written while an earlier action's `refresh()` is out shows at once instead of waiting for that refresh; a refresh landing older than a guess no longer brings back a row another pending guess removed; and an unkeyed list's guess written after a correction composes on what the screen shows, not on the truth beneath it (no duplicated, empty or missing rows).
6+
7+
New DEV diagnostic `OPTIMISTIC_WRITE_BEFORE_LOAD`: an optimistic write to a source whose first answer has not landed (`createOptimistic(async fn)`, `createOptimisticStore(fn, seed)`) throws in development and makes no guess — before its first answer the source is loading, not a value to be optimistic over. Keep pending items in a separate list until the source loads, or disable the action until then. Production behaviour is unchanged.

‎documentation/solid-2.0/08-dev-diagnostics.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,31 @@ const bump = action(async function* () {
7878
});
7979
```
8080

81+
#### `OPTIMISTIC_WRITE_BEFORE_LOAD`
82+
83+
**Message:** "Optimistic write to a source that has not loaded yet. Before its first answer the source is loading, not showing a value to be optimistic over. Keep the pending items in a separate list (an outbox) until the source loads, or disable the action until the source has loaded."
84+
85+
An optimistic setter ran before its source's first answer landed: `createOptimistic(fn)` whose async `fn` has not resolved, or `createOptimisticStore(fn, seed)` whose derive has not landed (a seed does not count — it is a draft, never shown). Until then the source is loading, so there is nothing on screen to be optimistic over (ruled 2026-11-03, #4656). Dev throws at the setter and makes no guess; inside an `action` the action rejects. Production is unchanged. `createOptimistic(value)`, `createOptimisticStore(value)` and a source that has landed once are never flagged. Repair: keep the items written before the load in a separate list (an outbox) and render it beside the source, or disable the action (the input) until the source has loaded.
86+
87+
```js
88+
const [todos, setTodos] = createOptimisticStore(() => api.list(), []);
89+
const add = action(function* (todo) {
90+
setTodos(s => {
91+
s.push(todo); // throws in dev while the first `api.list()` is out
92+
});
93+
yield api.add(todo);
94+
refresh(todos);
95+
});
96+
97+
// Fix: offer the action only once the list has loaded — inside the same
98+
// <Loading> as the list, the button is not there before the first answer…
99+
<Loading fallback={<p>loading</p>}>
100+
<For each={todos}>{t => <li>{t.title}</li>}</For>
101+
<button onClick={() => add(next())}>Add</button>
102+
</Loading>;
103+
// …or keep pre-load items in their own list (an outbox) and render both.
104+
```
105+
81106
#### `STORE_WRITE_OUTSIDE_SETTER`
82107

83108
**Message:** "Writing store property \"n\" outside its setter was ignored. Stores are read-only outside the setter's draft: use `setStore(s => { s.n = value })`."
@@ -989,6 +1014,7 @@ The runtime derives a request's trace itself in every tier — the W3C `tracepar
9891014
| ---------------------------------- | ---------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9901015
| `REACTIVE_WRITE_IN_OWNED_SCOPE` | error | write | Reactive write/invalidation inside component/computation |
9911016
| `ASYNC_STORE_SETTER` | error | write | Store setter callback returned a Promise (setters are synchronous transactions) |
1017+
| `OPTIMISTIC_WRITE_BEFORE_LOAD` | error | write | Optimistic write to a source whose first answer has not landed; no guess is made |
9921018
| `STORE_WRITE_OUTSIDE_SETTER` | warn | write | Store proxy written, deleted from, or defined on outside its setter; the write is ignored (once per store object and key) |
9931019
| `PENDING_ASYNC_UNTRACKED_READ` | error | async | Reading pending async outside tracking scope |
9941020
| `ASYNC_OUTSIDE_LOADING_BOUNDARY` | warn | async | Async computation outside Loading boundary (non-halting; root mount is deferred) |

‎packages/signals/docs/RULES-DERIVED.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ An override's lifetime is that of the hold it was made over — in the usual sha
292292

293293
**From:** F-11, F-1, F-6. **Scenarios:** S-33, S-44.
294294

295-
When an override's own source answers (its own landing, or a sync recompute from an upstream change): an equal answer confirms silently — nothing re-runs; a different answer corrects — derivations re-derive from the truth now as the hold's work (downstream refetches restart at once, no waterfall), the screen and untracked reads keep what the screen showed until the commit, `latest()` answers the truth and `isPending()` reads `true` while they differ, and the correction reveals with the hold. "Keep the override" means keep what _showed_: a guess the screen never displayed — its reveal held on its own downstream flight, including through a shown `Loading` — is void at the correction, and untracked reads see the committed value, as the screen does. A later landing equal to the override restores it as the graph's value.
295+
When an override's own source answers (its own landing, or a sync recompute from an upstream change): an equal answer confirms silently — nothing re-runs; a different answer corrects — derivations re-derive from the truth now as the hold's work (downstream refetches restart at once, no waterfall), the screen and untracked reads keep what the screen showed until the commit, `latest()` answers the truth and `isPending()` reads `true` while they differ, and the correction reveals with the hold. "Keep the override" means keep what _showed_: a guess the screen never displayed — its reveal held on its own downstream flight, including through a shown `Loading` — is void at the correction, and untracked reads see the committed value, as the screen does. A later landing equal to the override restores it as the graph's value. **A write before the first landing is no guess (ruled 2026-11-03, maintainer, #4656):** "if it hadn't landed it isn't optimistic, its loading" (09:22); "Write before load in the non optimistic case gets squashed.. optimistic is odd one because its visible. Idd be ok with it erroring I think"; "I guess it could be in a second list but then it wouldn't have this problem" (09:27); "That or chat input is disabled until it loads" (09:29). An optimistic write to a source whose first answer has not landed — a `createOptimistic` signal's, an optimistic store's, keyed or `key: null`, seed or not — throws `OPTIMISTIC_WRITE_BEFORE_LOAD` in DEV and guesses nothing; the remedies are a separate list (an outbox) for the pending items, or the action disabled until the source has loaded. Production behaviour is unchanged (not specified). So nothing in this rule, or in D-35's re-base, meets a first load.
296296

297297
A keyed store's arrangement guess (rows by key) that the screen showed is not voided by a correction: the truth folds beneath it (one the screen never showed is void, as above). Derivations outside the lane re-derive from the truth now and join the hold, `until`/`resolve` keep their postures over it (an `until` outside the lane reads the truth and joins the hold, D-31), and `latest()` shows the hold's world whole. Lane passes, untracked reads and the screen keep the guess until the commit, and at the commit rows match by key. So a row the truth returns keeps its identity, a row another tab added shows at the commit, and the first of two overlapping actions confirming does not void the second's guess (2026-10-21). A folded lane's list pass inside a frame that already has a transaction reads that frame's stagings as the screen, as a verdict reader does, so it never pairs the truth's length with the guess's rows.
298298

0 commit comments

Comments
 (0)