fix: surface app errors in gateway logs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user