@@ -141,22 +141,45 @@ export interface SolidStartOptions {
141141 env ?: EnvPluginOptions ;
142142
143143 /**
144- * Options controlling which files are processed as server functions
145- * (inclusion / exclusion filters for the `"use server"` transform).
144+ * Options for server functions: which files the `"use server"` transform
145+ * processes (inclusion / exclusion filters), and what happens when a server
146+ * function throws.
146147 */
147148 serverFunctions ?: Pick < ServerFunctionsOptions , "filter" > & {
148149 /**
149- * Path to a module whose default export is called with whatever a server
150- * function threw , before it is serialized into the response. Return a
151- * value to send it in place of what was thrown, or `undefined` to send the
152- * original .
150+ * Path to a module whose default export handles whatever a server function
151+ * throws , before it reaches the client. Use it to report failures to a
152+ * monitoring service, or to replace an error carrying internal detail with
153+ * one that is safe to send .
153154 *
154- * Naming the module here rather than registering a handler at runtime
155- * keeps the app in sole control of it: no dependency can reach into the
156- * running server and take over reporting.
155+ * Only server function calls made over the network run through it. A
156+ * server function called during rendering runs in process and throws
157+ * straight to its caller, and errors from API routes never reach it
158+ * either.
157159 *
158- * The module is bundled into the server only, so it may import server-only
159- * code such as a monitoring SDK.
160+ * The export is called synchronously with the thrown value, and what it
161+ * returns decides what the client sees:
162+ *
163+ * - `undefined` (or `null`) sends what was thrown, unchanged.
164+ * - A `Response` is passed through unchanged, which keeps a thrown
165+ * `redirect()` working.
166+ * - Any other value is sent in place of what was thrown, and the client
167+ * call rejects with it.
168+ *
169+ * Control flow reaches the export the same way errors do, so a handler
170+ * that replaces everything it sees turns redirects into errors.
171+ *
172+ * Whatever is sent gets serialized to the client along with its own
173+ * properties, so an error meant to be safe to expose must not carry
174+ * internal detail.
175+ *
176+ * The return value is not awaited, so make the export a plain function
177+ * rather than an `async` one, and report failures with calls that do not
178+ * need awaiting.
179+ *
180+ * Type the export as `ServerFunctionErrorHandler` from
181+ * `@solidjs/start/server`. The module is bundled into the server only, so
182+ * it may import server-only code such as a monitoring SDK.
160183 *
161184 * @example "src/server-fn-error.ts"
162185 */
0 commit comments