diff --git a/Changes.md b/Changes.md index 78a30ec56..c663d41e6 100644 --- a/Changes.md +++ b/Changes.md @@ -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 diff --git a/lib/protocol/sequences/Quit.js b/lib/protocol/sequences/Quit.js index 04438d125..3c34c5820 100644 --- a/lib/protocol/sequences/Quit.js +++ b/lib/protocol/sequences/Quit.js @@ -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()); };