This commit is contained in:
2025-05-24 01:00:30 +00:00
parent cb52446f65
commit f2e9ff0a51
38 changed files with 223 additions and 175 deletions

View File

@ -613,6 +613,12 @@ export class UnifiedDeliveryQueue extends EventEmitter {
// Stop processing
this.stopProcessing();
// Clear the check timer to prevent memory leaks
if (this.checkTimer) {
clearInterval(this.checkTimer);
this.checkTimer = undefined;
}
// If using disk storage, make sure all items are persisted
if (this.options.storageType === 'disk') {
const pendingWrites: Promise<void>[] = [];

View File

@ -146,6 +146,35 @@ export class UnifiedRateLimiter extends EventEmitter {
}
}
/**
* Destroy the rate limiter and clean up all resources
*/
public destroy(): void {
// Stop the cleanup interval
this.stop();
// Clear all maps to free memory
this.counters.clear();
this.ipCounters.clear();
this.patternCounters.clear();
// Clear blocks
if (this.config.blocks) {
this.config.blocks = {};
}
// Clear statistics
this.stats = {
activeCounters: 0,
totalBlocked: 0,
currentlyBlocked: 0,
byPattern: {},
byIp: {}
};
logger.log('info', 'UnifiedRateLimiter destroyed');
}
/**
* Clean up expired counters and blocks
*/