test(gateway): avoid brittle shutdown timer assertion

Co-authored-by: Han Kim <han.kim@Bowcaster.local>
Co-authored-by: Peter Steinberger <peter@steipete.me>
This commit is contained in:
Han Kim
2026-05-30 13:39:49 -07:00
committed by GitHub
parent a20b2dc740
commit b7232db1b0

View File

@@ -937,11 +937,12 @@ describe("createGatewayCloseHandler", () => {
it("fails shutdown when http server close still hangs after force close", async () => {
vi.useFakeTimers();
const closeAllConnections = vi.fn();
const close = createGatewayCloseHandler(
createGatewayCloseTestDeps({
httpServer: {
close: () => undefined,
closeAllConnections: vi.fn(),
closeAllConnections,
closeIdleConnections: vi.fn(),
} as never,
}),
@@ -953,7 +954,13 @@ describe("createGatewayCloseHandler", () => {
);
await vi.advanceTimersByTimeAsync(HTTP_CLOSE_GRACE_MS + HTTP_CLOSE_FORCE_WAIT_MS);
await closeExpectation;
expect(vi.getTimerCount()).toBe(0);
expect(closeAllConnections).toHaveBeenCalledTimes(1);
expect(
mocks.logWarn.mock.calls.some(([message]) =>
String(message).includes("http-server close exceeded 1000ms"),
),
).toBe(true);
});
it("labels warnings for multiple HTTP servers with their index", async () => {