From 9c32c2bf26131fadc1af655e473cbbfde301525c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 15 Apr 2026 10:46:37 +0100 Subject: [PATCH] fix(gateway): clear fired close timeout handles --- src/gateway/server-close.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gateway/server-close.ts b/src/gateway/server-close.ts index ba8913ffab3..5e0311e6381 100644 --- a/src/gateway/server-close.ts +++ b/src/gateway/server-close.ts @@ -16,8 +16,12 @@ const HTTP_CLOSE_GRACE_MS = 1_000; const HTTP_CLOSE_FORCE_WAIT_MS = 5_000; function createTimeoutRace(timeoutMs: number, onTimeout: () => T) { - let timer: ReturnType | null = setTimeout(() => { - timer = null; + let timer: ReturnType | null = null; + timer = setTimeout(() => { + if (timer) { + clearTimeout(timer); + timer = null; + } resolve(onTimeout()); }, timeoutMs); timer.unref?.();