Skip to content

Commit

Permalink
Fix error when server sends RST on QUIT
Browse files Browse the repository at this point in the history
fixes #1811
  • Loading branch information
dougwilson committed Oct 2, 2017
1 parent 55c20da commit bcb9348
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -9,6 +9,7 @@ you spot any mistakes.
* Add new Amazon RDS ca-central-1 certificate CA to Amazon RDS SSL profile #1809
* Add `mysql.raw()` to generate pre-escaped values #877 #1821
* Fix "changedRows" to work on non-English servers #1819
* Fix error when server sends RST on `QUIT` #1811
* Fix typo in insecure auth error message
* Support `mysql_native_password` auth switch request for Azure #1396 #1729 #1730
* Update `sqlstring` to 2.3.0
Expand Down
22 changes: 22 additions & 0 deletions lib/protocol/sequences/Quit.js
Expand Up @@ -11,8 +11,30 @@ function Quit(options, callback) {
}

Sequence.call(this, options, callback);

this._started = false;
}

Quit.prototype.end = function end(err) {
if (this._ended) {
return;
}

if (!this._started) {
Sequence.prototype.end.call(this, err);
return;
}

if (err && err.code === 'ECONNRESET' && err.syscall === 'read') {
// Ignore read errors after packet sent
Sequence.prototype.end.call(this);
return;
}

Sequence.prototype.end.call(this, err);
};

Quit.prototype.start = function() {
this._started = true;
this.emit('packet', new Packets.ComQuitPacket());
};

0 comments on commit bcb9348

Please sign in to comment.