Skip to content

Commit 839e286

Browse files
committed
fix(pools): Emit 'clear' once transporter is idle and all connections are closed
1 parent 493635f commit 839e286

4 files changed

Lines changed: 502 additions & 472 deletions

File tree

‎lib/mailer/index.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class Mail extends EventEmitter {
8787
this.transporter.on('idle', (...args) => {
8888
this.emit('idle', ...args);
8989
});
90+
91+
// indicates if the sender has became idle and all connections are terminated
92+
this.transporter.on('clear', (...args) => {
93+
this.emit('clear', ...args);
94+
});
9095
}
9196

9297
/**

‎lib/smtp-pool/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ class SMTPPool extends EventEmitter {
406406
this._continueProcessing();
407407
}, 50);
408408
} else {
409+
if (!this._closed && this.idling && !this._connections.length) {
410+
this.emit('clear');
411+
}
412+
409413
this._continueProcessing();
410414
}
411415
});

0 commit comments

Comments
 (0)