From 4acc4bb24faa6b2bdde54d439342818392f3b773 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 13 Jan 2025 14:41:23 +0100 Subject: [PATCH] chore: unref timer from https://nodejs.org/api/timers.html#timeoutunref When called, the active Timeout object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the Timeout object's callback is invoked. --- src/MemoryCache.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MemoryCache.ts b/src/MemoryCache.ts index b7fc58c..b32cc86 100644 --- a/src/MemoryCache.ts +++ b/src/MemoryCache.ts @@ -14,6 +14,9 @@ export default class MemoryCache { private readonly maxItemCount: number ) { this.timer = setInterval(this.deleteExpiredItems, itemsExpirationCheckIntervalInSecs * 1000); + if( this.timer.unref ){ + this.timer.unref(); + } } storePermanentItem(key: K, value: V): void {