Skip to content

Commit bcb9348

Browse files
committed
Fix error when server sends RST on QUIT
fixes #1811
1 parent 55c20da commit bcb9348

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ you spot any mistakes.
99
* Add new Amazon RDS ca-central-1 certificate CA to Amazon RDS SSL profile #1809
1010
* Add `mysql.raw()` to generate pre-escaped values #877 #1821
1111
* Fix "changedRows" to work on non-English servers #1819
12+
* Fix error when server sends RST on `QUIT` #1811
1213
* Fix typo in insecure auth error message
1314
* Support `mysql_native_password` auth switch request for Azure #1396 #1729 #1730
1415
* Update `sqlstring` to 2.3.0

lib/protocol/sequences/Quit.js

+22
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,30 @@ function Quit(options, callback) {
1111
}
1212

1313
Sequence.call(this, options, callback);
14+
15+
this._started = false;
1416
}
1517

18+
Quit.prototype.end = function end(err) {
19+
if (this._ended) {
20+
return;
21+
}
22+
23+
if (!this._started) {
24+
Sequence.prototype.end.call(this, err);
25+
return;
26+
}
27+
28+
if (err && err.code === 'ECONNRESET' && err.syscall === 'read') {
29+
// Ignore read errors after packet sent
30+
Sequence.prototype.end.call(this);
31+
return;
32+
}
33+
34+
Sequence.prototype.end.call(this, err);
35+
};
36+
1637
Quit.prototype.start = function() {
38+
this._started = true;
1739
this.emit('packet', new Packets.ComQuitPacket());
1840
};

0 commit comments

Comments
 (0)