Skip to content

Commit

Permalink
fix: remove data handler when flushing command queue
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed May 7, 2016
1 parent 8a84482 commit b1c761c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/cluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ Cluster.prototype.refreshSlotsCache = function (callback) {
};

/**
* Flush offline queue and command queue with error.
* Flush offline queue with error.
*
* @param {Error} error - The error object to send to the commands
* @private
Expand Down
14 changes: 8 additions & 6 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ Redis.prototype.disconnect = function (reconnect) {
if (this.status === 'wait') {
eventHandler.closeHandler(this)();
} else {
if (this.stream) {
this.stream.removeAllListeners('data');
}
this.connector.disconnect();
}
};
Expand Down Expand Up @@ -359,9 +356,14 @@ Redis.prototype.flushQueue = function (error) {
item.command.reject(error);
}

while (this.commandQueue.length > 0) {
item = this.commandQueue.shift();
item.command.reject(error);
if (this.commandQueue.length > 0) {
if (this.stream) {
this.stream.removeAllListeners('data');
}
while (this.commandQueue.length > 0) {
item = this.commandQueue.shift();
item.command.reject(error);
}
}
};

Expand Down

0 comments on commit b1c761c

Please sign in to comment.