fix: log production request failures

This commit is contained in:
2026-07-20 13:48:47 +05:30
parent b3e5e5b999
commit aa2595ec01
55 changed files with 126 additions and 89 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/dev-server",
"version": "0.2.67",
"version": "0.2.68",
"type": "module",
"main": "src/index.ts",
"exports": {
+27 -4
View File
@@ -207,8 +207,20 @@ async function checkAuth(
headers: forwardAuthHeaders(req),
redirect: "manual",
});
if (!res.ok) return forwardAuthFailure(res, verifyUrl);
} catch {
if (!res.ok) {
if (res.status >= 500) {
const requestUrl = new URL(req.url);
console.error(
`[wrnexus] forward-auth verifier error: ${req.method} ${requestUrl.pathname} via ${verifyUrl} returned ${res.status}`,
);
}
return forwardAuthFailure(res, verifyUrl);
}
} catch (error) {
console.error(
`[wrnexus] forward-auth verifier unavailable: ${verifyUrl}`,
error instanceof Error ? (error.stack ?? error.message) : error,
);
return new Response("Auth service unavailable", { status: 503 });
}
}
@@ -373,7 +385,14 @@ export async function startGateway(opts: GatewayOptions): Promise<RunningGateway
child.once("exit", (code, signal) => {
if (stopping || target.child !== child) return;
const delay = gatewayRestartDelay(mode, code, signal);
if (delay === null) return;
if (delay === null) {
if (code !== 0 || signal) {
console.error(
`[wrnexus] app '${target.name}' stopped unexpectedly (${signal ? `signal ${signal}` : `code ${code}`})`,
);
}
return;
}
if (delay > 0) {
console.error(`[wrnexus] app '${target.name}' exited (code ${code}); retrying in 1.2s…`);
setTimeout(launch, delay);
@@ -480,7 +499,11 @@ export async function startGateway(opts: GatewayOptions): Promise<RunningGateway
body,
redirect: "manual",
});
} catch {
} catch (error) {
console.error(
`[wrnexus] gateway proxy error: ${req.method} ${url.pathname}${target.name} (${target.origin})`,
error instanceof Error ? (error.stack ?? error.message) : error,
);
res = new Response(`Gateway: app '${target.name}' is unavailable.`, { status: 502 });
}
if (sec.headers) res = applyEdgeHeaders(res);
+6 -1
View File
@@ -788,7 +788,12 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
);
return compressResponse(req, res);
} catch (err) {
if (mode === "development") console.error(err);
const app = process.env.WRNEXUS_APP_NAME ?? "app";
const detail =
err instanceof Error ? (err.stack ?? `${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)));
}
}