fix(gateway): keep liveness probes working when config reload fails (#126736)

This commit is contained in:
Peter Steinberger
2026-08-20 09:52:29 -07:00
committed by GitHub
parent d8c3d94fb1
commit ddb49f61ca
2 changed files with 18 additions and 7 deletions
+17 -6
View File
@@ -903,21 +903,32 @@ describe("gateway probe endpoints", () => {
});
});
it("serves /healthz before loading gateway config", async () => {
it("serves liveness probes before loading gateway config or resolving auth", async () => {
const getRuntimeConfig = vi.fn(() => {
throw new Error("config load blocked");
});
const getResolvedAuth = vi.fn(() => {
getRuntimeConfig();
return AUTH_NONE;
});
await withGatewayServer({
prefix: "probe-healthz-before-config",
prefix: "probe-liveness-before-config-auth",
resolvedAuth: AUTH_NONE,
overrides: { getRuntimeConfig },
overrides: { getRuntimeConfig, getResolvedAuth },
run: async (server) => {
const { res, getBody } = await sendGatewayRequest(server, { path: "/healthz" });
for (const path of ["/health", "/healthz"]) {
for (const method of ["GET", "HEAD"] as const) {
const { res, getBody } = await sendGatewayRequest(server, { path, method });
expect(res.statusCode).toBe(200);
expect(getBody()).toBe(JSON.stringify({ ok: true, status: "live" }));
expect(res.statusCode, `${method} ${path}`).toBe(200);
expect(getBody(), `${method} ${path}`).toBe(
method === "HEAD" ? "" : JSON.stringify({ ok: true, status: "live" }),
);
}
}
expect(getRuntimeConfig).not.toHaveBeenCalled();
expect(getResolvedAuth).not.toHaveBeenCalled();
},
});
});
+1 -1
View File
@@ -257,7 +257,7 @@ export function createGatewayHttpServer(opts: {
req,
res,
requestPath,
getResolvedAuth(),
resolvedAuth,
[],
false,
rateLimiter,