Skip to content

Commit

Permalink
correction : doesn't throw error to command that are already finished
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Mar 27, 2018
1 parent ad14637 commit 71a82f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions src/connection.js
Expand Up @@ -213,7 +213,14 @@ class Connection {
const killCon = new Connection(this.opts);
killCon.query("KILL " + this.info.threadId, () => {
const err = Utils.createError("Connection destroyed, command was killed", true, self.info);
if (self._receiveCmd) {
if (!this._receiveCmd || !this._receiveCmd.onPacketReceive) {
while (
(this._receiveCmd = this._receiveQueue.shift()) &&
!this._receiveCmd.onPacketReceive
);
}

if (self._receiveCmd && self._receiveCmd.onPacketReceive) {
if (self._receiveCmd.onResult) {
self._receiveCmd.onResult(err);
} else {
Expand All @@ -222,10 +229,12 @@ class Connection {
}
let receiveCmd;
while ((receiveCmd = self._receiveQueue.shift())) {
if (receiveCmd.onResult) {
receiveCmd.onResult(err);
} else {
receiveCmd.emit("error", err);
if (receiveCmd.onPacketReceive) {
if (receiveCmd.onResult) {
receiveCmd.onResult(err);
} else {
receiveCmd.emit("error", err);
}
}
}
process.nextTick(() => {
Expand Down Expand Up @@ -493,13 +502,13 @@ class Connection {
this._socket.destroy();
this._closing = true;

if (this._receiveCmd && this._receiveCmd.onResult) {
if (this._receiveCmd && this._receiveCmd.onPacketReceive && this._receiveCmd.onResult) {
setImmediate(this._receiveCmd.onResult, err);
}

let receiveCmd;
while ((receiveCmd = this._receiveQueue.shift())) {
if (receiveCmd.onResult) {
if (receiveCmd.onPacketReceive && receiveCmd.onResult) {
setImmediate(receiveCmd.onResult, err);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-connection.js
Expand Up @@ -159,7 +159,7 @@ describe("connection", () => {
//using sequence engine
if (!shareConn.isMariaDB() || !shareConn.hasMinVersion(10, 1)) this.skip();

this.timeout(20000);
this.timeout(30000);
const array1 = [];
array1[999] = "a";
const str = array1.fill("a").join("");
Expand Down

0 comments on commit 71a82f7

Please sign in to comment.