Skip to content

Commit f47ee47

Browse files
committed
Merge next into claude/fix-4639-gaps
2 parents dbadaf5 + dd5f9d1 commit f47ee47

30 files changed

Lines changed: 1814 additions & 78 deletions

‎.changeset/broadcast-live.md‎

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

5-
Experimental `broadcast(fn)`: a live server function whose answer is the same for every viewer. It implies `live` (and so `GET`); at the live address every caller with the same arguments shares one server render, and each viewer is a tap on it. A viewer that joins later gets the frame as it stands, then the shared batches; the render ends with its last viewer. The outer body still runs per call (auth, redirects), and the shared render runs under its own request event, so per-viewer state such as the router's query cache never reaches it.
5+
`broadcast(fn)`: a live server function whose answer is the same for every viewer. It implies `live` (and so `GET`); at the live address every caller with the same arguments shares one server render, and each viewer is a tap on it. A viewer that joins later gets the frame as it stands, then the shared batches; the render ends with its last viewer. The outer body still runs per call (auth, redirects), and the shared render runs under its own request event, so per-viewer state such as the router's query cache never reaches it.
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+
An `<Errored>` heals once no reader it caught still reads the failed source, instead of staying on its fallback after navigating to another branch (#4644). This covers an error read only by memos (a `<Show>`/`<Match>` condition), and a source something outside the boundary still reads: a hoisted memo, a derived store or projection, a reader under another `<Errored>`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"solid-js": patch
3+
"@solidjs/signals": patch
4+
---
5+
6+
A non-keyed `<Show>`'s or `<Match>`'s narrowed accessor read inside an `isPending()` thunk no longer throws the stale-value error for a branch that mounted in the flush its condition landed in, so the thunk's later reads link and the verdict flips (#4648). The exemption holds only inside a verdict window (`isPending` / `latest`): a plain read of the accessor while its branch's opening is held still throws, rather than hand out the committed falsy.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/web": patch
3+
---
4+
5+
Fail `renderToStream` when an asynchronous value cannot be serialized after its key was handed to the default serializer, if that happens before the first flush (an awaited render, or before the shell went out). The render tears down without calling `onCompleteAll` and nothing is sent (#4647). Synchronous serialization failures and custom serializers keep their existing behavior.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/web": patch
3+
---
4+
5+
`renderToStream`: an async value that resolves to something the serializer cannot handle after the first flush (midstream) now rejects its key on the client instead of leaving it pending forever (#4647) — and with it every promise or async iterable inside the value that already went out (a nested promise, an async iterable's later items), and every other key on the same value. The failure is still reported as `{ kind: "render", handling: "serialize" }` and the render completes; the payload settles the key's promise with an error that says it is a serialization failure and names the key (the failure's own text stays on the server). The hydrating read throws into the nearest `<Errored>`, whose fallback replaces the server-rendered content until `reset()` or an input change reruns the computation as a client fetch. With no `<Errored>` above, it is uncaught like any rejected key. Before the first flush the render fails instead (see the other changeset).

‎documentation/solid-2.0/12-ssr-http.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ Said plainly, `httpHeader` is a **shell-time API**. Headers declared by streamed
168168

169169
A render failure reaches the client on several roads: the error an `<Errored>` caught, serialized so the client hydrates the same fallback; a rejected async source serialized into the stream; a `<Loading>` fragment rejecting its `_fr` promise; a frame stream's error chunks. On every one of them the **non-dev** build hands the client a generic `Error` (`"Internal Server Error"`) in place of a plain thrown value — `message`, `cause` and own properties stay on the server — the same policy the server-function wire applies ([RFC 10](10-server-functions.md#thrown-errors-sanitized-by-default)). A `"use server"` function called in-process during a render never touches that wire, so without this the production page load leaked exactly what the RPC withheld ([#3468](https://github.com/solidjs/solid/issues/3468)).
170170

171+
One more road carries no thrown value at all: a hydration value that failed to serialize after the first flush ([#4647](https://github.com/solidjs/solid/issues/4647), maintainer ruling, 2026-11-03). Its key — and every promise or async iterable the failed value had already sent, nested ones included — rejects on the client with a fixed `Error` whose message names the key (`Serialization failed: the hydration value for key "…" could not be serialized on the server`), in **all** builds: the message carries no server data, and the serializer's own error stays on the server, with the error hook (`handling: "serialize"`). The reading computation throws it into the nearest `<Errored>` like any other rejected key. Before the first flush the render fails instead, so nothing reaches the client.
172+
171173
The boundary sanitizes _before_ rendering its fallback, and serializes the same replacement: the fallback is rendered on the server with the error and hydrates against the record, so the two must agree. A fallback that prints `err().message` therefore shows the generic message in production, as it would for a server-function failure. `markSafeError` is the escape hatch on both wires — a branded error passes through with its own properties. An Error reached as a _value_ (never thrown — a form's field errors, say) is data and passes as written.
172174

173175
The dev/prod line is the build variant: the `development` export condition's server artifacts keep full fidelity; the production and observe artifacts sanitize. The observe tier records each replacement once as `SERVER_ERROR_SANITIZED` with `data.source: "ssr"` (advisory; `data.error` the original, `data.wire` what replaced it), beside the `SSR_RENDER_ERROR_CONTAINED` finding that carries the failure itself — the server keeps the truth, the wire gets the generic.
@@ -193,8 +195,8 @@ renderToStream(code, { onError });
193195
handleServerFunctionRequest(request, { onError });
194196
```
195197

196-
- **Called once per error object per `kind` per request, at first sight** (per render when no request is in scope — never once per process: an error object reused across requests is heard, and mapped, by each), with where the failure was met. A direct server-function call that throws during SSR inside an `<Errored>` is heard twice, as `server-function` and then as `render`, so `kind: "render"` alone tells you a render failed; the wire value is the first one the hook returned. `kind: "render"` — `fallback` (an `<Errored>` rendered its fallback; `boundary` is its hydration id and `boundaryPath` its component labels — where the error was **met** — while `ownerPath` is where it was **thrown**, the labels up the owner chain it escaped, when the compiler emitted them), `client` (a `<Loading>` fragment rejected, the client re-renders the subtree — unless the `<Loading>` is all of an `<Errored>`'s content: that `<Errored>` draws its fallback into the fragment, reports `fallback`, and the hydrating client adopts it, [#4287](https://github.com/solidjs/solid/issues/4287)), `failed` (nothing contained it; the request fails — including a synchronous throw out of `renderToString` or `renderToStream`'s first pass, reported before it reaches the caller), `serialize` (a hydration value would not serialize and the render went on without it — reported for a render that passed `onError`, as seroval's own `onError` always was). `kind: "server-function"` — `thrown` (the body threw; `functionId`, and `direct: true` for an in-process call during SSR) or `channel` (a rejection or throw escaping through the result graph, the head already committed). `kind: "request"` is always `failed`: a failure that fails the request outside any render or server function the runtime reports (a middleware throw, a setup step), reported by the framework's request handler through `reportRequestFailure(error, event)`. A render failure, synchronous throws included, is reported as `render`, so a handler that catches one and passes it to `reportRequestFailure` adds nothing. It has no per-request tier, so only the ambient hook hears it. `event` is the request, when the failure happened inside one, and always for `kind: "request"`.
197-
- **The return is the wire value**: rendered into the fallback, serialized for hydration, sent as the RPC error. `undefined` leaves the default policy in place (generic outside dev, fidelity in dev). A returned value is the author's intent — like a `wrapInvocation` mapping — and is not sanitized again; `markSafeError` is not needed on it. Ignored for `failed` and `serialize`, which have no wire. One road a mapping does not reach: a rejected async source's serialized rejection is encoded the moment the source rejects, ahead of the boundary, and carries the default policy's value; the hydrating client renders from the boundary's record, which carries the mapping.
198+
- **Called once per error object per `kind` per request, at first sight** (per render when no request is in scope — never once per process: an error object reused across requests is heard, and mapped, by each), with where the failure was met. A direct server-function call that throws during SSR inside an `<Errored>` is heard twice, as `server-function` and then as `render`, so `kind: "render"` alone tells you a render failed; the wire value is the first one the hook returned. `kind: "render"` — `fallback` (an `<Errored>` rendered its fallback; `boundary` is its hydration id and `boundaryPath` its component labels — where the error was **met** — while `ownerPath` is where it was **thrown**, the labels up the owner chain it escaped, when the compiler emitted them), `client` (a `<Loading>` fragment rejected, the client re-renders the subtree — unless the `<Loading>` is all of an `<Errored>`'s content: that `<Errored>` draws its fallback into the fragment, reports `fallback`, and the hydrating client adopts it, [#4287](https://github.com/solidjs/solid/issues/4287)), `failed` (nothing contained it; the request fails — including a synchronous throw out of `renderToString` or `renderToStream`'s first pass, reported before it reaches the caller), `serialize` (a hydration value would not serialize — reported for a render that passed `onError`, as seroval's own `onError` always was. A value that fails as it is handed over never reaches the client, and the render goes on without it ([#4227](https://github.com/solidjs/solid/issues/4227)). An async source's landing that fails is a key the client already holds as pending, [#4647](https://github.com/solidjs/solid/issues/4647): **before the first flush** — an awaited `renderToStream`, or a stream whose shell has not gone out — the render **fails** like a rejection there: nothing is sent, `onCompleteAll` does not fire, and the hook hears only `serialize`; **after the first flush** (midstream, where the response cannot be failed cleanly) the key — and any promise or async iterable inside its value that already went out — rejects on the client with an error that says the value could not be serialized and names the key, so the reading computation throws into the nearest `<Errored>`, whose fallback replaces the server's content until `reset()` or an input change reruns it as a client fetch — uncaught like any rejected key with no `<Errored>` above — and the render completes. A custom `serializer`'s late failure is its own to settle; the render completes. `renderToString` refuses async values outright, so it has no late case). `kind: "server-function"` — `thrown` (the body threw; `functionId`, and `direct: true` for an in-process call during SSR) or `channel` (a rejection or throw escaping through the result graph, the head already committed). `kind: "request"` is always `failed`: a failure that fails the request outside any render or server function the runtime reports (a middleware throw, a setup step), reported by the framework's request handler through `reportRequestFailure(error, event)`. A render failure, synchronous throws included, is reported as `render`, so a handler that catches one and passes it to `reportRequestFailure` adds nothing. It has no per-request tier, so only the ambient hook hears it. `event` is the request, when the failure happened inside one, and always for `kind: "request"`.
199+
- **The return is the wire value**: rendered into the fallback, serialized for hydration, sent as the RPC error. `undefined` leaves the default policy in place (generic outside dev, fidelity in dev). A returned value is the author's intent — like a `wrapInvocation` mapping — and is not sanitized again; `markSafeError` is not needed on it. Ignored for `failed`, which has no wire, and for `serialize`, whose only wire — the midstream key rejection ([#4647](https://github.com/solidjs/solid/issues/4647)) — is the fixed message naming the key, never the serializer's error or a mapping of it. One road a mapping does not reach: a rejected async source's serialized rejection is encoded the moment the source rejects, ahead of the boundary, and carries the default policy's value; the hydrating client renders from the boundary's record, which carries the mapping.
198200
- **Once means once across roads.** A direct server-function call that throws during SSR is met first by the invocation (`kind: "server-function"`, `direct: true`) and then by the `<Errored>` that contains it; the boundary reuses the verdict — the same replacement in the fallback and the record — and does not report again. A `<Loading>` re-pull recurring the same throw is the same object, the same verdict. The observe tier keeps the multi-event picture (an `"invocation"` record _and_ an `SSR_RENDER_ERROR_CONTAINED` finding) for consumers that want it.
199201
- **Two tiers, as `wrapInvocation` has.** Ambient: `configureServerErrors({ onError })`, once per process, registered on `globalThis` under a registered symbol so a bundled server build and an instrumented `--import`ed module share it — and the only tier that sees direct in-process calls. Per request, overriding it: `onError` on `renderToStream`/`renderToString`, and on `handleServerFunctionRequest` for the call it dispatches. A throwing hook is reported on the console and treated as silent. With no hook anywhere, a failure that fails the request goes to `console.error` — never silent. A synchronous render throw is the exception: it is rethrown to the caller, whose own handling (or `reportRequestFailure`) decides.
200202
- **One listener, every failure.** A `renderToStream` `onError` written for the old single-argument shape keeps working; it now hears every handled failure, not only the one that fails the request — filter on `context.handling === "failed"` for the old behaviour. The hook fires in every tier, dev included; only the _default_ mapping differs by tier.

‎packages/signals/src/boundaries.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,23 @@ function caughtBelow(b: Boundary, r: Computed<any>, s: Computed<any>): boolean {
381381
return false;
382382
}
383383

384+
/** `n` reads `s`, directly or through derivations wherever they live (a
385+
* hoisted memo, a derived store's derive, a loading boundary's output). Each
386+
* upstream node is walked once (`seen`), so a shared upstream graph costs its
387+
* size, not its paths. */
388+
function reads(n: Computed<any>, s: Computed<any>, seen?: Set<any>): any {
389+
for (let l = n._deps, h; l; l = l._nextDep)
390+
if ((h = l._dep) === s || ((seen ||= new Set()).size < seen.add(h).size && reads(h, s, seen)))
391+
return 1;
392+
}
393+
384394
/** Drop the readers that settled or died. Settled: a loading reader no
385-
* longer pending; an error's source neither errored nor in flight. A reader
395+
* longer pending; an error's source neither errored nor in flight, or no
396+
* longer read by the reader that caught it: the boundary waits on what threw
397+
* only while such a reader is alive. One that re-ran clean (the tree, a
398+
* memo-only read gated away) holds nothing, and a reader outside the
399+
* boundary — a hoisted memo, a derived store, a reader under another
400+
* boundary — never caught its error (D-39, #4644). A reader
386401
* that landed but is held (its value staged in a transaction) is not: the
387402
* content reveals at the commit, with its run. The tree is: the output reads
388403
* it and enters the transaction itself (its committed value shows until the
@@ -412,7 +427,7 @@ export function prune(b: Boundary, pass?: boolean | 0): number {
412427
// settled before it ran, a fresh boundary revealed into a hold its
413428
// pass then went pending in, which waited on that flight (#4568).
414429
if (
415-
((r._statusFlags | s._statusFlags) & mask &&
430+
((r._statusFlags & mask || (s._statusFlags & mask && reads(r, s))) &&
416431
!(mask & STATUS_ERROR && caughtBelow(b, r, s))) ||
417432
(mask & STATUS_ERROR && s._config & CONFIG_STAGED_ERROR) ||
418433
(r._config & CONFIG_VERDICT && r._flags & REACTIVE_IN_HEAP)

‎packages/signals/src/core/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export {
1616
setSnapshotCapture,
1717
markSnapshotScope,
1818
releaseSnapshotScope,
19-
clearSnapshots
19+
clearSnapshots,
20+
verdict
2021
} from "./core.js";
2122
export {
2223
enableExternalSource,

‎packages/signals/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export {
3838
* outside dev builds.
3939
*/
4040
export { setConsoleFooter } from "./core/index.js";
41+
/** @internal The verdict windows' read (core.ts): non-null while a `latest()` or `isPending()` window is open — solid-js's narrowed accessors (#4648). */
42+
export { verdict } from "./core/index.js";
4143
/** @internal The flush round counter (scheduler.ts): hydration's served pass tells its own round from a later one. */
4244
export { clock } from "./core/index.js";
4345
/** @internal Dev duplicate-copy check: solid-js marks components and context reads. */

0 commit comments

Comments
 (0)