fix(timers): unref background interval timers so they don't block clean shutdown (#4117)

Integrated into release/v3.8.28 (r8)
This commit is contained in:
NOXX - Commiter
2026-06-17 23:26:10 +03:00
committed by GitHub
parent 996ac484f6
commit d6ea20bfda
3 changed files with 6 additions and 0 deletions

View File

@@ -79,6 +79,8 @@ class AutoRefreshDaemon {
this.timerId = setInterval(() => {
this.check().catch(() => {});
}, this.checkIntervalMs);
// Don't keep the process alive solely for this periodic daemon.
(this.timerId as { unref?: () => void })?.unref?.();
console.log(
`[AutoRefreshDaemon] Started — checking ${this.credentialStore.size} credentials every ${this.checkIntervalMs / 1000}s`

View File

@@ -25,6 +25,8 @@ export class HealthChecker {
this.consecutiveFailures = 0;
this.currentHealth = "unknown";
this.timer = setInterval(() => void this.poll(), this.intervalMs);
// Don't keep the process alive solely for the health poller.
(this.timer as { unref?: () => void })?.unref?.();
}
stop(): void {

View File

@@ -440,6 +440,8 @@ function startHeartbeat(server: WebSocketServer): void {
sendTo(client.ws, { type: "pong" } as WsServerMessage);
}
}, HEARTBEAT_INTERVAL_MS);
// Don't keep the process alive solely for the heartbeat (it is also cleared on close).
(interval as { unref?: () => void })?.unref?.();
server.on("close", () => clearInterval(interval));
}