This commit is contained in:
2025-05-23 01:00:37 +00:00
parent 4905595cbb
commit 7344bf0f70
5 changed files with 119 additions and 33 deletions

View File

@ -370,7 +370,16 @@ export class SmtpServer implements ISmtpServer {
);
}
await Promise.all(closePromises);
// Add timeout to prevent hanging on close
await Promise.race([
Promise.all(closePromises),
new Promise<void>((resolve) => {
setTimeout(() => {
SmtpLogger.warn('Server close timed out after 3 seconds, forcing shutdown');
resolve();
}, 3000);
})
]);
this.server = null;
this.secureServer = null;
@ -774,12 +783,20 @@ export class SmtpServer implements ISmtpServer {
await Promise.all(destroyPromises);
// Destroy the adaptive logger singleton to clean up its timer
const { adaptiveLogger } = await import('./utils/adaptive-logging.js');
if (adaptiveLogger && typeof adaptiveLogger.destroy === 'function') {
adaptiveLogger.destroy();
}
// Clear recovery state
this.recoveryState = {
recovering: false,
currentRecoveryAttempt: 0,
connectionFailures: 0,
lastRecoveryAttempt: 0,
recoveryCooldown: 5000,
maxRecoveryAttempts: 3,
lastError: null
currentRecoveryAttempt: 0
};
SmtpLogger.info('All SMTP server components destroyed');