Repository navigation
Public request-level failure report for the server error hook (kind: "request") #3723
Description
Summary
configureServerErrors promises the ambient hook hears "the failure that fails a request", but the runtime can only report failures it meets itself — inside renderToStream (kind: "render") or inside a server-function dispatch (kind: "server-function"). A failure that happens in the framework's request handler before any render exists (Start middleware, setup, the render-mode module throwing) has no site and no public way to be reported. The only funnel is reportServerError, which is solid-js/internal.
Where this bites
solidjs/solid-vite-plugin#383 (design in solidjs/solid-vite-plugin#382) adds containment at the generated Start handler edge: a thrown Response becomes the response, anything else becomes a 500 instead of rejecting out to the host (Vite overlay / plain-text 500 / e.message echoed by the example server / configureServerErrors never hearing it). To report the failure it has to:
- import
reportServerErrorfromsolid-js/internalinto every production Start build (the header says "NOT public API… may change or vanish in any release"); - read
globalThis[Symbol.for("solid-js/server/errors")].hookto decide whether toconsole.error— duplicatingfailRender's fallback policy (packages/web/src/server.ts~L2061–2069); - label the site
{ kind: "render", handling: "failed" }becauseServerErrorSite.kindhas nothing else. A monitor using the documented`solid.${kind}.${handling}`mechanism files middleware throws as render failures.
Proposal
Public request-level failure report on @solidjs/web/server, same policy as failRender, written once in the package that owns the slot:
// ServerErrorSite
kind: "render" | "server-function" | "request";
// handling for "request" is always "failed"; `event` always present.
export function reportRequestFailure(error: unknown, event: RequestEvent): void;
// = reportServerError(error, { kind: "request", handling: "failed", event }, null)
// + console.error(error) iff no ambient hook (per-request hooks don't exist at this layer)Hook return ignored, as for every handling: "failed". The once-per-error ledger already applies, so an in-process server-function failure reported as server-function/thrown that then propagates through the middleware is not reported twice.
No change to renderToStream, onError, the server-function handler, or any wire format. configureServerErrors docs updated so "the failure that fails a request" is true for the pre-render case too.
Public API
ServerErrorSite.kindgains"request".- New export
reportRequestFailure(error, event)from@solidjs/web/server.
Related, found while reviewing #383 (separate issues if you want them tracked)
- An async render failure before the shell with no boundary leaves the response pending forever (
createSSRResponse.end()never resolves the head). - A framework-side throw after
next()has already returned a rendered page cannot cancel that render's stream; it keeps running into a buffer nobody reads.
Once this ships (rc.14), #383 shrinks to one import + one call; the containment shape and its fixtures stay as written.
— Claude via Cursor
Activity
everton-dgn commentedon Oct 2, 2026
I can take this one if you haven't started on it. The shape I have in mind:
reportRequestFailure(error, event)exported from@solidjs/webitself, next toconfigureServerErrorsin the server entry, with a no-op inserver-mock.tsasconfigureServerErrorshas. There's no./serversubpath in the package'sexportstoday, and I'd rather not add one for a single function."request"added toServerErrorSite.kindinpackages/solid/src/server/signals.ts, so the PR carries a changeset forsolid-jsand one for@solidjs/web.failRender:reportServerError(error, { kind: "request", handling: "failed", event }, null), thenconsole.error(error)only when no ambient hook is registered. A test pins the ledger case, where aserver-function/thrownfailure that then escapes the middleware isn't reported a second time.Once it's published, #383 drops its
solid-js/internalimport and calls this instead. Should I go ahead?feat(web): report request failures met before any render (#3763)
ryansolid commentedon Oct 4, 2026