From 2c023a368ec0f10af70a6c4a2f37b429c8f93ae0 Mon Sep 17 00:00:00 2001 From: Adrian Pascu Date: Wed, 29 Jul 2026 17:22:35 +0200 Subject: [PATCH 1/3] Update the `serverFunctions.onError` reference --- .../v2/reference/config/solid-start.mdx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/routes/solid-start/v2/reference/config/solid-start.mdx b/src/routes/solid-start/v2/reference/config/solid-start.mdx index d28e3a09c..a6f17a59d 100644 --- a/src/routes/solid-start/v2/reference/config/solid-start.mdx +++ b/src/routes/solid-start/v2/reference/config/solid-start.mdx @@ -137,9 +137,13 @@ solidStart({ - **Type:** `string` -Path to a module whose default export handles values thrown by server functions before SolidStart serializes them into a response. +Path to a module whose default export handles values thrown by server functions before SolidStart serializes them into a response. Only calls arriving over the network reach it. The module is bundled only into the server, so it can import server-only code. -The handler can report the original value and return a safer replacement for the client. Return `undefined` to preserve the original value. The module is bundled only into the server, so it can import server-only code. +The export runs synchronously, and its return value is not awaited. + +- Return `undefined` or `null` to preserve the original value. +- Return a `Response` unchanged to pass it through, which keeps a thrown `redirect` working. See [Return Responses](/solid-start/v2/advanced/return-responses). +- Return any other value to send it in place of the original, serialized to the client along with its own properties. ```tsx title="vite.config.ts" solidStart({ @@ -149,17 +153,21 @@ solidStart({ }); ``` +The module it names, `src/server-function-error.ts`: + ```ts title="src/server-function-error.ts" import type { ServerFunctionErrorHandler } from "@solidjs/start/server"; +import { captureException } from "./your-monitoring-client"; const onServerFunctionError: ServerFunctionErrorHandler = (thrown) => { - console.error(thrown); - - if (thrown instanceof Error) { - return new Error("The server function failed."); + // redirect() throws a Response, so returning it preserves that control flow. + if (thrown instanceof Response) { + return thrown; } - return undefined; + captureException(thrown); // or console.error, or any reporter + + return new Error("The server function failed."); }; export default onServerFunctionError; From 7f301176435b4370dea44653d6b73c4554c9f151 Mon Sep 17 00:00:00 2001 From: Adrian Pascu Date: Thu, 30 Jul 2026 10:05:05 +0200 Subject: [PATCH 2/3] Document the failure semantics of the awaited `onError` handler --- .../solid-start/v2/reference/config/solid-start.mdx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/routes/solid-start/v2/reference/config/solid-start.mdx b/src/routes/solid-start/v2/reference/config/solid-start.mdx index b2c784270..829a0ea06 100644 --- a/src/routes/solid-start/v2/reference/config/solid-start.mdx +++ b/src/routes/solid-start/v2/reference/config/solid-start.mdx @@ -141,13 +141,11 @@ solidStart({ Path to a module whose default export handles values thrown by server functions before SolidStart serializes them into a response. Only calls arriving over the network reach it. The module is bundled only into the server, so it can import server-only code. -The handler can report the original value and provide a safer replacement for the client. It may be asynchronous, and SolidStart awaits it before serializing the response, allowing a monitoring service to flush first. +The handler can report the original value and provide a safer replacement for the client. It may be `async`: SolidStart awaits it before serializing the response, so a monitoring service can flush first. If the handler itself throws or rejects, it is ignored and the original value is sent. -The value it returns, or resolves to, decides what the client sees: - -- `undefined` or `null` preserves the original value. -- A `Response` is passed through unchanged, which keeps a thrown `redirect` working. See [Return Responses](/solid-start/v2/advanced/return-responses). -- Any other value is sent in place of the original, serialized to the client along with its own properties. +- Return `undefined` or `null` to preserve the original value. +- Return a `Response` unchanged to pass it through, which keeps a thrown `redirect` working. See [Return Responses](/solid-start/v2/advanced/return-responses). +- Return any other value to send it in place of the original, serialized to the client along with its own properties. ```tsx title="vite.config.ts" solidStart({ From 3810a7e4292a1512f298c7dce2677f235ff6d7ba Mon Sep 17 00:00:00 2001 From: Adrian Pascu Date: Thu, 30 Jul 2026 10:15:57 +0200 Subject: [PATCH 3/3] Tighten the wording for a failing `onError` handler --- src/routes/solid-start/v2/reference/config/solid-start.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/solid-start/v2/reference/config/solid-start.mdx b/src/routes/solid-start/v2/reference/config/solid-start.mdx index 829a0ea06..51602e7d1 100644 --- a/src/routes/solid-start/v2/reference/config/solid-start.mdx +++ b/src/routes/solid-start/v2/reference/config/solid-start.mdx @@ -141,7 +141,7 @@ solidStart({ Path to a module whose default export handles values thrown by server functions before SolidStart serializes them into a response. Only calls arriving over the network reach it. The module is bundled only into the server, so it can import server-only code. -The handler can report the original value and provide a safer replacement for the client. It may be `async`: SolidStart awaits it before serializing the response, so a monitoring service can flush first. If the handler itself throws or rejects, it is ignored and the original value is sent. +The handler can report the original value and provide a safer replacement for the client. It may be `async`: SolidStart awaits it before serializing the response, so a monitoring service can flush first. If the handler itself throws or rejects, the original value is sent as if no handler were configured. - Return `undefined` or `null` to preserve the original value. - Return a `Response` unchanged to pass it through, which keeps a thrown `redirect` working. See [Return Responses](/solid-start/v2/advanced/return-responses).