mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
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:
@@ -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`
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user