fix(delivery): prevent throttle reset timer from firing after stop and avoid scheduling duplicate timers
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-02-26 - 5.2.3 - fix(delivery)
|
||||
prevent throttle reset timer from firing after stop and avoid scheduling duplicate timers
|
||||
|
||||
- add throttleResetTimer property to track scheduled throttle-reset timeout
|
||||
- clear throttleResetTimer when stopping to prevent it firing after shutdown
|
||||
- clear existing throttleResetTimer before scheduling a new one and null it when fired to avoid duplicate timers and potential leaks
|
||||
|
||||
## 2026-02-12 - 5.2.2 - fix(deps)
|
||||
bump dependencies: @push.rocks/smartrust to ^1.2.1, lru-cache to ^11.2.6
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartmta',
|
||||
version: '5.2.2',
|
||||
version: '5.2.3',
|
||||
description: 'A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.'
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ export class MultiModeDeliverySystem extends EventEmitter {
|
||||
private activeDeliveries: Set<string> = new Set();
|
||||
private running: boolean = false;
|
||||
private throttled: boolean = false;
|
||||
private throttleResetTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private rateLimitLastCheck: number = Date.now();
|
||||
private rateLimitCounter: number = 0;
|
||||
private emailServer?: UnifiedEmailServer;
|
||||
@@ -211,7 +212,13 @@ export class MultiModeDeliverySystem extends EventEmitter {
|
||||
}
|
||||
|
||||
this.running = false;
|
||||
|
||||
|
||||
// Clear throttle reset timer to prevent it firing after stop
|
||||
if (this.throttleResetTimer) {
|
||||
clearTimeout(this.throttleResetTimer);
|
||||
this.throttleResetTimer = null;
|
||||
}
|
||||
|
||||
// Wait for active deliveries to complete
|
||||
if (this.activeDeliveries.size > 0) {
|
||||
logger.log('info', `Waiting for ${this.activeDeliveries.size} active deliveries to complete`);
|
||||
@@ -776,7 +783,11 @@ export class MultiModeDeliverySystem extends EventEmitter {
|
||||
|
||||
// Schedule throttle reset
|
||||
const resetDelay = 60000 - elapsed;
|
||||
setTimeout(() => {
|
||||
if (this.throttleResetTimer) {
|
||||
clearTimeout(this.throttleResetTimer);
|
||||
}
|
||||
this.throttleResetTimer = setTimeout(() => {
|
||||
this.throttleResetTimer = null;
|
||||
this.throttled = false;
|
||||
this.rateLimitLastCheck = Date.now();
|
||||
this.rateLimitCounter = 0;
|
||||
|
||||
Reference in New Issue
Block a user