From 8a09b9d4be746aca012e608deec0a88c5b7aaebb Mon Sep 17 00:00:00 2001 From: Adrian Pascu Date: Thu, 16 Jul 2026 07:10:17 +0200 Subject: [PATCH] Report server function errors to an observability hook before serialization --- packages/start/src/fns/handler.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/start/src/fns/handler.ts b/packages/start/src/fns/handler.ts index 8f21cf740..5bc6dad01 100644 --- a/packages/start/src/fns/handler.ts +++ b/packages/start/src/fns/handler.ts @@ -114,6 +114,11 @@ export async function handleServerFunction(h3Event: H3Event) { h3Event.res.headers.set("content-type", "text/plain"); return serializeToJSONStream(result); } catch (x) { + // Give monitoring a chance to observe server-function failures before + // they are serialized into the response, since no error hook fires for + // them today. Thrown Responses are control flow (redirects, forbidden), + // not errors. + if (!(x instanceof Response)) (globalThis as any).__reportServerFnError?.(x); if (x instanceof Response) { if (singleFlight && instance) { x = await handleSingleFlight(event, x);