Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Emit error on unexpected close

  • Loading branch information...
commit 111da1673611b307a4af259efe091a1e5409741b 1 parent 219b785
@andris9 authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/client.js
View
8 lib/client.js
@@ -379,6 +379,10 @@ SMTPClient.prototype._onDrain = function(){
* @event
*/
SMTPClient.prototype._onClose = function(){
+ if([this._actionGreeting, this._actionIdle, this.close].indexOf(this._currentAction) < 0){
+ return this._onError(new Error("Connection closed unexpectedly"));
+ }
+
this.stage = "close";
this._destroy();
@@ -517,6 +521,10 @@ SMTPClient.prototype.close = function(){
this.log("Closing connection to the server");
}
var closeMethod = "end";
+
+ // Clear current job
+ this._currentAction = this._actionIdle;
+
if (this.stage === "init") {
// Clear connection timeout timer if other than timeout error occurred
clearTimeout(this._connectionTimeout);
Please sign in to comment.
Something went wrong with that request. Please try again.