fix: surface app errors in gateway logs

This commit is contained in:
2026-07-20 14:26:27 +05:30
parent aa2595ec01
commit 2b4083c6db
56 changed files with 147 additions and 86 deletions
+7 -1
View File
@@ -791,10 +791,16 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
const app = process.env.WRNEXUS_APP_NAME ?? "app";
const detail =
err instanceof Error ? (err.stack ?? `${err.name}: ${err.message}`) : String(err);
const message = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
console.error(
`[wrnexus] unhandled request error (${app}) ${req.method} ${url.pathname}\n${detail}`,
);
return compressResponse(req, secure(renderError(err, mode)));
const response = secure(renderError(err, mode));
// Gateway-managed production apps bind to loopback. Carry a bounded,
// encoded diagnostic to the parent gateway so centralized log collectors
// can explain child failures; the gateway always strips this header.
response.headers.set("x-wrnexus-internal-error", encodeURIComponent(message.slice(0, 500)));
return compressResponse(req, response);
}
}