From ce190b0f977d437ab74dc1ed47927bfcb8d47407 Mon Sep 17 00:00:00 2001 From: luin Date: Fri, 21 Aug 2015 01:08:59 +0800 Subject: [PATCH] Fix errors when sending command to a failed cluster. #56 --- lib/cluster.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cluster.js b/lib/cluster.js index 57bb7474..60b444e2 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -370,8 +370,8 @@ Cluster.prototype.sendCommand = function (command, stream, node) { command.reject(new Error('Cluster is ended.')); return; } + var redis; if (_this.status === 'ready') { - var redis; if (node && node.redis) { redis = node.redis; } else if (_.includes(Command.FLAGS.ENTER_SUBSCRIBER_MODE, command.name) || @@ -396,6 +396,8 @@ Cluster.prototype.sendCommand = function (command, stream, node) { if (node && !node.redis) { node.redis = redis; } + } + if (redis) { redis.sendCommand(command, stream); } else if (_this.options.enableOfflineQueue) { _this.offlineQueue.push({