fix: evict expired SESSION_MANAGER_CACHE entries on TTL miss

isSessionManagerCached() checks TTL before returning stale hits but
never deletes expired entries from the Map. They accumulate
indefinitely over the lifetime of a long-running gateway.

Delete the expired entry when the TTL check fails so the Map stays
bounded to active sessions.

Closes #51820
This commit is contained in:
Karan Uppal
2026-03-22 18:40:29 +00:00
committed by Peter Steinberger
parent 055f62e43e
commit 30090e4895

View File

@@ -42,7 +42,11 @@ function isSessionManagerCached(sessionFile: string): boolean {
}
const now = Date.now();
const ttl = getSessionManagerTtl();
return now - entry.loadedAt <= ttl;
if (now - entry.loadedAt > ttl) {
SESSION_MANAGER_CACHE.delete(sessionFile);
return false;
}
return true;
}
export async function prewarmSessionFile(sessionFile: string): Promise<void> {