Skip to content

Commit 28fcc9b

Browse files
ryansolidClaude via Cursor
andauthored
fix(signals): LOADING_ON_OUTSIDE_HOLD reports only the same-source outside read (#3540) (#3584)
* fix(signals): LOADING_ON_OUTSIDE_HOLD reports only the same-source outside read (#3540) The DEV diagnostic fired in two shapes. Only the first is sound: - At the change, same source (kept): `on` re-arms the boundary while the very async source it is waiting on is also read by a live reader outside it, so the frame is held on that source and the fallback can never be seen. Deterministic and structural; `data.source` names the source and the fix is to move the outside read under the boundary. The message now states that claim; `latest()` in `on` stays a parenthetical capability (#3578 ruling). - After the fact (removed): the frame was held — by the write's action, or by other pending data — past the content's landing, so the staged swap was cleared before display. That is a race the developer does not control (the nested boundary's data may simply be faster than the frame's hold) and a fallback that loses it is a legitimate outcome, not a defect. The engine cannot distinguish "the action awaited exactly this data" from "the action awaited something else that happened to be slower", so the rule is unsound. Removed with it: `devHeldSweep`, `CollectionQueue._swapUnseen` and `_devHeldSweep`, the `_checkSources` DEV drop, and the scheduler's DEV-only parked-finalize walk (`devSweepBoundaryChildren`). `_settled`, `_judgeHeld` and `_output` stay — they carry the pre-verdict boundary judgment (#3581). Prod core floor unchanged (boundaries.ts is shed from that fixture; the scheduler branch was DEV-folded); core+Loading −9 B prod, −647 B dev. Tests: the after-the-fact pins flip to "not reported" (frame-following 5., rearm-reveal held-action cases, the web held-action spec); the same-source pins tighten on the new message; one new pin for a frame held by OTHER pending data that outlasts the content with no action — no report, the content reveals at the commit. Docs, CHEATSHEET, `Loading` JSDoc and the two pending changesets that announced the removed rule updated to match. Co-authored-by: Claude via Cursor <[email protected]> * chore(size): re-set the createStore cap after the CollectionQueue field removal (#3584) Measured against next (4d7638c), brotli: - signals: + createStore: 16,866 B vs 16,805 (+61 B); cap 16.85 -> 16.90 KB. Minified bundle length unchanged; the delta is the prop mangler's short-name reshuffle after two _ props left CollectionQueue. - app: CSR, observe tier + attribution engine enabled: 27,767 B, under the 27.80 KB cap `next` already re-set in #3587 — no change here. - boundaries.ts is -9 B minified on both tiers; scheduler.ts 0 B. - All other scenarios under cap: core floor 9,675 (+4), isPending/latest 12,411 (-20), simple-app 12,489 (+16), hydrating 20,655 (-49), hydrating + stores 30,825 (-55), CSR 15,779 (+36), CSR observe 17,293 (+18), frames 11,384 (0). Co-authored-by: Claude via Cursor <[email protected]> --------- Co-authored-by: Claude via Cursor <[email protected]>
1 parent 9adf007 commit 28fcc9b

13 files changed

Lines changed: 180 additions & 152 deletions

‎.changeset/fix-boundary-pending-fallback-reveal.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@solidjs/signals": patch
33
---
44

5-
A Loading boundary whose fallback reads something not ready now reveals its content as soon as the content lands, instead of waiting for the fallback's own flight (#3540). The boundary's output pass derives from its `_disabled` switch, not its tree, so only the boundary sweep re-runs it — and that sweep ran at the commit, after the verdict the output's own pending read kept parking. Such a boundary is now judged before the verdict, under the transaction, so its output re-runs, reads the tree and drops the fallback's read ahead of the verdict. Boundaries whose fallback is ready are unaffected. The DEV `LOADING_ON_OUTSIDE_HOLD` after-the-fact rule recognizes a swap cleared this way as never displayed.
5+
A Loading boundary whose fallback reads something not ready now reveals its content as soon as the content lands, instead of waiting for the fallback's own flight (#3540). The boundary's output pass derives from its `_disabled` switch, not its tree, so only the boundary sweep re-runs it — and that sweep ran at the commit, after the verdict the output's own pending read kept parking. Such a boundary is now judged before the verdict, under the transaction, so its output re-runs, reads the tree and drops the fallback's read ahead of the verdict. Boundaries whose fallback is ready are unaffected.

‎.changeset/loading-on-follows-frame.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Loading `on` follows the frame (#3540). When a dependency of `on` changes, the b
77

88
Read `latest()` in `on` (or any display-ahead state: `isPending()`, an optimistic signal) to keep the previous behavior — the fallback shows now, beside the still-held frame.
99

10-
If the same data the boundary is waiting on is also read outside it, the frame waits on that read and no fallback appears; DEV warns `LOADING_ON_OUTSIDE_HOLD` with the fix (read `latest()` in `on`, or move the outside read under the boundary). The same code fires after the fact when the write's action outlasts the data — nothing outside reads the source, but the action parks the frame past the content's landing, so the fallback is never displayed (a frame held by other data is a race, not a warning).
10+
If the same data the boundary is waiting on is also read outside it, the frame waits on that read and no fallback appears; DEV warns `LOADING_ON_OUTSIDE_HOLD` with the fix (move the outside read under the boundary). A frame held by the write's action or by other data past the content's landing shows no fallback either — a race, not a warning.
1111

1212
`Errored` no longer accepts `on` (nor `createErrorBoundary` an `on` option). It was added in #3556 and never released in a stable — rc-only. Retry through the `reset` the fallback receives (`fallback={(err, reset) => ...}`), or re-mount the boundary on the dependency (`<Show keyed when={id()}>`).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solidjs/signals": patch
3+
"solid-js": patch
4+
---
5+
6+
The DEV `LOADING_ON_OUTSIDE_HOLD` diagnostic now reports only the deterministic shape: `on` re-armed a Loading boundary while the very async source it is waiting on is also read by a live reader outside it, so the frame is held on that source and the fallback can never be seen (`data.source` names it; the fix is to move the outside read under the boundary). The after-the-fact report — the frame held by the write's action or by other pending data past the content's landing, so the staged fallback was cleared before display — is removed: that is a race the developer does not control, a fallback that loses it is a legitimate outcome, and the engine cannot tell an action that awaited exactly this data from one that awaited something slower.

‎documentation/solid-2.0/05-async-data.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ on={id()}: [A] → [B + spinner] → [B + comments] the fallback lands wit
7979

8080
The shell keeps showing A until `product(2)` lands; the spinner arrives with B, not beside A for a change the page does not reflect yet. If the comments land before the shell, no fallback is ever shown.
8181

82-
One shape shows no fallback at all: when the data the boundary is waiting on is also read outside it (a sibling `<Loading>` over the same `comments(id)`, an `isPending` on it in the header), or the write's `action` stays open until the data lands. The frame waits on that read, so by the time it commits the content is ready and the fallback was never needed. In development the `LOADING_ON_OUTSIDE_HOLD` diagnostic names the source. The fix is structural: move the outside read under the boundary so one hold owns the data, or — during an `action` — show the wait with `isPending()` or an optimistic value, which is what a hold's stale content is for. The old content is on screen and valid the whole time; a `Loading` fallback says it is not.
82+
One shape shows no fallback at all: when the data the boundary is waiting on is also read outside it (a sibling `<Loading>` over the same `comments(id)`, an `isPending` on it in the header), or the write's `action` stays open until the data lands. The frame waits on that read, so by the time it commits the content is ready and the fallback was never needed. The first of these is structural — no ordering of the flights can show that fallback — and in development the `LOADING_ON_OUTSIDE_HOLD` diagnostic names the source; the fix is to move the outside read under the boundary so one hold owns the data. The second is a race the fallback may still win (an action that ends first shows it with the commit), and is not reported: during an `action`, show the wait with `isPending()` or an optimistic value, which is what a hold's stale content is for. The old content is on screen and valid the whole time; a `Loading` fallback says it is not.
8383

8484
It is possible to show the fallback beside the still-held frame anyway: a display-ahead read in `on` — `latest(id)`, `isPending()`, an optimistic signal — says the change is already on screen, so the fallback lands there too:
8585

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,23 @@ render(
128128

129129
#### `LOADING_ON_OUTSIDE_HOLD`
130130

131-
**Message:** "`on` re-armed a Loading boundary, but `comments` is also read outside it and holds the frame: the fallback lands with the frame and will not be seen until that read settles. Move the outside read under the boundary so one hold owns the data, or show the wait with `isPending()`. (Reading `latest()` in `on` shows the fallback now, beside the held frame.)" — or, after the fact: "… but the frame was held until its content settled, so the fallback was never displayed. The old content stayed valid for the whole wait; show the wait with `isPending()` or an optimistic value. (Reading `latest()` in `on` shows the fallback now, beside the held frame.)"
131+
**Message:** "`on` re-armed a Loading boundary, but `comments` is also read outside it and holds the frame: the fallback can never be seen — the frame waits on the very source the boundary is waiting on. Move the outside read under the boundary so one hold owns the data. (Reading `latest()` in `on` shows the fallback now, beside the held frame.)"
132132

133133
**Severity:** `warn` (non-halting)
134134

135-
A `<Loading on={…}>` dependency changed while something under the boundary was pending, so the boundary stopped waiting on its content and staged its fallback. The fallback follows the frame — it lands with the change that caused it — and in this shape that frame waits on the very data the boundary is waiting on, so by the time it commits the content is ready and the fallback is never shown. Two triggers, one code:
135+
A `<Loading on={…}>` dependency changed while something under the boundary was pending, so the boundary stopped waiting on its content and staged its fallback. The fallback follows the frame — it lands with the change that caused it — and here that frame waits on the very async source the boundary is waiting on, because a live reader **outside** the boundary also reads it: a sibling `<Loading>` over the same data, an `isPending()` on it in the header, a plain read in the shell. That reader holds the frame until the data lands, so by the time the frame commits the content is ready and the fallback can never be shown. The diagnostic fires once, at the change, and `data.source` names the source.
136136

137-
- **At the change** (`data.source` names the source): the same async source is also read by a live reader outside the boundary — a sibling `<Loading>` over the same data, an `isPending()` on it in the header, a plain read in the shell. That reader holds the frame until the data lands.
138-
- **After the fact** (no `data.source`): nothing outside reads the data, but the write happened inside an `action` that stays open until the data lands (a refresh the action awaits, for instance). The action parks the frame past the content's landing, so the staged fallback is cleared before it is displayed. Reported once, when the content settles. A frame held by _other_ data is not reported — that is a race the fallback may still win.
137+
This is the only shape reported, because it is the only one that is deterministic and structural: no ordering of the flights can show this fallback. A frame held past the content's landing by something _else_ — the write's `action` staying open, other pending data the shell is waiting on — also shows no fallback, but that is a race the fallback may still win (the action ending first, the shell landing first, shows it with the commit), a fallback that loses it is a legitimate outcome, and the engine cannot tell "the action awaited exactly this data" from "the action awaited something slower". Nothing is reported for it.
139138

140-
The frame is holding because the old content is still on screen and still valid; a `Loading` fallback would say it is not. So the fix is structural, or it acknowledges the wait in place:
139+
The frame is holding because the old content is still on screen and still valid; a `Loading` fallback would say it is not. The fix is structural — one hold owns the data:
141140

142141
```jsx
143-
// Warns: B reads the same data() and holds the frame — A's fallback never shows.
142+
// Warns: B reads the same data() and holds the frame — A's fallback can never show.
144143
<Loading on={id()} fallback={<Spinner />}>{data()}</Loading>
145144
<Loading fallback={<Spinner />}>{data()}</Loading>
146145

147146
// Fix: one boundary owns the read.
148147
<Loading on={id()} fallback={<Spinner />}>{data()} {data()}</Loading>
149-
150-
// Or, for the action shape: keep the content, show the wait.
151-
<Show when={isPending(data)}><Spinner /></Show>
152-
{data()}
153148
```
154149

155150
A display-ahead read in `on` — `on={latest(id)}`, `isPending()`, an optimistic signal — is not reported: it says the change is already on screen, so the fallback lands now beside the held frame. That is a capability the diagnostic notes, not the recommended shape: it puts the new page's loading state inside the old page. See [RFC 05](05-async-data.md#loading-on-prop-dependencies-that-show-the-fallback-again).
@@ -788,7 +783,7 @@ The runtime derives a request's trace itself in every tier — the W3C `tracepar
788783
| `SETTLE_WALK_UNINITIALIZED_SOURCE` | error | lifecycle | Internal: settle walk reached a source that never produced a value (reported) |
789784
| `STRICT_READ_UNTRACKED` | warn | strict-read | Untracked reactive read in component/effect body |
790785
| `PENDING_ASYNC_FORBIDDEN_SCOPE` | warn | async | Pending async read in trackedEffect/onSettled |
791-
| `LOADING_ON_OUTSIDE_HOLD` | warn | async | `<Loading on>` changed but the frame waits on its data (read outside, or the action outlasts it): fallback never shown |
786+
| `LOADING_ON_OUTSIDE_HOLD` | warn | async | `<Loading on>` changed but its data is also read outside the boundary and holds the frame: the fallback can never be seen |
792787
| `NO_OWNER_EFFECT` | warn | lifecycle | Effect created without reactive owner |
793788
| `NO_OWNER_CLEANUP` | warn | lifecycle | `onCleanup` called without owner |
794789
| `NO_OWNER_BOUNDARY` | warn | lifecycle | Boundary created without owner |

0 commit comments

Comments
 (0)