You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5662bbb
Browse filesBrowse the repository at this point in the historyBrowse files
The server error hook — `configureServerErrors({ onError })` from `@solidjs/web`, `onServerError` on `renderToStream`/`renderToString` and on `handleServerFunctionRequest`: the prod-tier seam through which a server integration hears every failure the runtime handles and may say what the client receives instead (sentry-integration-plan C6, #3468 part 3).
7
+
8
+
Until now a production build reported only the failure that fails a request (`renderToStream`'s `onError`); an `<Errored>` fallback rendered, a `<Loading>` fragment rejected and re-rendered by the client, and a server-function throw sanitized onto the wire were observe-tier findings only. The hook is called **once per error object, at first sight**, with where the failure was met — `kind: "render"` (`fallback` / `client` / `failed`, with the boundary's hydration id and the component labels when compiled in) or `kind: "server-function"` (`thrown` / `channel`, with `functionId` and `direct` for an in-process call during SSR) — and the request event. Its return is the **wire value**: rendered into the fallback, serialized for hydration, sent as the RPC error; `undefined` keeps the default policy (generic outside dev, fidelity in dev); ignored for `failed`. A direct server-function call that throws during SSR is reported once as the function's failure, and the boundary that contains it reuses the verdict. Two tiers as `wrapInvocation` has: ambient (registered on `globalThis` under `Symbol.for("solid-js/server/errors")`, shared by a bundled build and an `--import`ed module) and per request, the latter winning. A throwing hook is reported and treated as silent. The hook fires in every tier; `onError` keeps its meaning.
9
+
10
+
Internals: `solid-js`'s server entry owns the verdict engine (`reportServerError` / `ssrSanitizeError` through `solid-js/internal`, one cache per error object); the SSR context gains `errorPolicy` and `flushed`; the `_fr` rejection reads its verdict at delivery. A rejected async source's own serialized rejection is encoded in the rejection's microtask, ahead of the boundary, and carries the default policy's value — the mapping reaches the boundary's record, which the hydrating client renders from; no tick is added to the error path. `SSR_ERROR_SANITIZED` carries `data.wire`.
Copy file name to clipboardExpand all lines: documentation/solid-2.0/08-dev-diagnostics.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -488,9 +488,9 @@ Finding (`error`, observe + dev). A server function threw and the non-dev wire r
488
488
489
489
#### `SSR_ERROR_SANITIZED`
490
490
491
-
**Message:** "[SSR_ERROR_SANITIZED] Render error replaced with a generic Error before reaching the client: TypeError: …"
491
+
**Message:** "[SSR_ERROR_SANITIZED] Render error replaced before reaching the client: TypeError: …"
492
492
493
-
Finding (`info`, observe + dev; channel only). A render failure was about to reach the client through one of SSR's roads — the record an `<Errored>` serializes so the client hydrates the same fallback, a rejected async source serialized into the stream, a `<Loading>` fragment's `_fr` rejection, a frame stream's error chunk (the fragment's, a live hole's, the root's) — and the non-dev wire replaced it with the generic `Error` (`"Internal Server Error"`), the same policy the server-function wire applies (`SERVER_FN_ERROR_SANITIZED`; a `"use server"` function called in-process during SSR never touches that wire, so before this the page load leaked what the RPC withheld — [#3468](https://github.com/solidjs/solid/issues/3468)). The boundary sanitizes _before_ rendering its fallback and serializes the same replacement, so fallback markup and record agree on hydration. Advisory because the failure itself is the `SSR_RENDER_ERROR_CONTAINED` finding's, which carries the original; this is the record of what the wire carried instead, `data.error` the original, once per original however many roads it took. A value branded with `markSafeError` passes through and is not reported; an Error reached as a _value_ — never thrown — is data and passes as the author wrote it (#3113's ruling). The dev build keeps full fidelity.
493
+
Finding (`info`, observe + dev; channel only). A render failure was about to reach the client through one of SSR's roads — the record an `<Errored>` serializes so the client hydrates the same fallback, a rejected async source serialized into the stream, a `<Loading>` fragment's `_fr` rejection, a frame stream's error chunk (the fragment's, a live hole's, the root's) — and the non-dev wire replaced it with the generic `Error` (`"Internal Server Error"`), the same policy the server-function wire applies (`SERVER_FN_ERROR_SANITIZED`; a `"use server"` function called in-process during SSR never touches that wire, so before this the page load leaked what the RPC withheld — [#3468](https://github.com/solidjs/solid/issues/3468)). The boundary sanitizes _before_ rendering its fallback and serializes the same replacement, so fallback markup and record agree on hydration. Advisory because the failure itself is the `SSR_RENDER_ERROR_CONTAINED` finding's, which carries the original; this is the record of what the wire carried instead — `data.error` the original, `data.wire` the replacement (the generic `Error`, or what the server error hook returned; [RFC 12](12-ssr-http.md#the-server-error-hook-configureservererrors--onservererror)) — once per original however many roads it took. The hook is the prod-tier seam for the same facts; these findings sit above it, recording whatever the wire actually carried. A value branded with `markSafeError` passes through and is not reported; an Error reached as a _value_ — never thrown — is data and passes as the author wrote it (#3113's ruling). The dev build keeps full fidelity.
Copy file name to clipboardExpand all lines: documentation/solid-2.0/10-server-functions.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,8 @@ Framework error hooks compose the same way: a `wrapInvocation`/`transformResult`
115
115
116
116
The same policy covers the SSR roads a failure takes to the client — an `<Errored>` record, a rejected async source in the stream, a fragment's rejection, a frame's error chunks — so a `"use server"` function called in-process during a render (which never touches this handler) cannot ship on the page what the RPC wire withholds; see [RFC 12](12-ssr-http.md#what-a-render-failure-looks-like-from-the-client) and `SSR_ERROR_SANITIZED` in [RFC 08](08-dev-diagnostics.md#ssr_error_sanitized). `markSafeError` is the one brand on both.
117
117
118
+
**The server error hook** ([RFC 12](12-ssr-http.md#the-server-error-hook-configureservererrors--onservererror)) hears every failure on this wire before the policy applies — `kind: "server-function"`, `handling: "thrown"` for the body's throw, `"channel"` for a failure escaping through the result graph, `functionId` and `direct` (an in-process call during SSR) named — once per error object; its return, when given, is what the client receives. Ambient through `configureServerErrors`, per request through `handleServerFunctionRequest(request, { onServerError })` (entry-only, like `wrapInvocation`: a direct call the body makes reports through the ambient hook). A `wrapInvocation` that maps errors keeps working; the hook is where a _reporting_ integration (an error monitor) plugs in without owning invocation policy.
119
+
118
120
### Single-flight
119
121
120
122
The protocol folds integration data (typically revalidated route data) into a mutation’s response, saving a round trip. Core standardizes only the wire shape and delivery; what the data _is_ — a data-only render, route preloads, a cache query — is entirely the integration’s business.
Copy file name to clipboardExpand all lines: documentation/solid-2.0/12-ssr-http.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,31 @@ A render failure reaches the client on several roads: the error an `<Errored>` c
140
140
141
141
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.
142
142
143
-
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 `SSR_ERROR_SANITIZED` (advisory; `data.error` the original), beside the `SSR_RENDER_ERROR_CONTAINED` finding that carries the failure itself — the server keeps the truth, the wire gets the generic.
143
+
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 `SSR_ERROR_SANITIZED` (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.
144
+
145
+
#### The server error hook: `configureServerErrors` / `onServerError`
146
+
147
+
Everything above is what the runtime does on its own. What it _handles_ — a fallback rendered, a fragment rejected and re-rendered by the client, a server-function throw sanitized — was, until this hook, invisible to a production consumer: the observe tier records it, a prod build has no `OBSERVE`, and `renderToStream`'s `onError` hears only the failure that fails the request. The server error hook is the prod-tier seam for both **reporting** and **mapping**:
// return nothing: the default wire policy applies
158
+
// return new Error("Something went wrong"): the client receives this instead
159
+
}
160
+
});
161
+
```
162
+
163
+
-**Called once per error object, at first sight**, with where the failure was met. `kind: "render"` — `fallback` (an `<Errored>` rendered its fallback; `boundary` is its hydration id, `ownerPath` the component labels when the compiler emitted them), `client` (a `<Loading>` fragment rejected, the client re-renders the subtree), `failed` (nothing contained it; the request fails, and `onError` hears it too). `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). `event` is the request, when the failure happened inside one.
164
+
-**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.
165
+
-**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.
166
+
-**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: `renderToStream(code, { onServerError })` / `renderToString(code, { onServerError })`, and `handleServerFunctionRequest(request, { onServerError })` for the call it dispatches. A throwing hook is reported on the console and treated as silent.
167
+
-**Where it runs.** The hook fires in every tier — dev included (an error monitor in development is ordinary); only the _default_ mapping differs by tier. `onError` on `renderToStream` keeps its meaning — the request failed — unchanged.
144
168
145
169
### The trace the request belongs to: `getTraceContext()`
0 commit comments