fix(mail): add periodic cleanup timers and proper shutdown handling for bounce manager and delivery queue; avoid mutating maps during iteration and prune stale rate-limiter stats to prevent memory growth
This commit is contained in:
@@ -231,7 +231,21 @@ export class UnifiedRateLimiter extends EventEmitter {
|
||||
this.domainCounters.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Clean stale stats.byIp entries for IPs that no longer have active counters or blocks
|
||||
for (const ip of Object.keys(this.stats.byIp)) {
|
||||
if (!this.ipCounters.has(ip) && !(this.config.blocks && ip in this.config.blocks)) {
|
||||
delete this.stats.byIp[ip];
|
||||
}
|
||||
}
|
||||
|
||||
// Clean stale stats.byPattern entries for patterns that no longer have active counters
|
||||
for (const pattern of Object.keys(this.stats.byPattern)) {
|
||||
if (!this.patternCounters.has(pattern)) {
|
||||
delete this.stats.byPattern[pattern];
|
||||
}
|
||||
}
|
||||
|
||||
// Update statistics
|
||||
this.updateStats();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user