Skip to content

Commit cfe4258

Browse files
authored
fix(Cluster): issues when setting enableOfflineQueue to false (#649)
Offline queue should be enabled on the internal cluster nodes so that we don't need to wait for the `ready` event before sending commands to the node.
1 parent 47654cd commit cfe4258

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/cluster/connection_pool.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ConnectionPool.prototype.findOrCreate = function (node, readOnly) {
4646
redis = this.nodes.all[node.key];
4747
if (redis.options.readOnly !== readOnly) {
4848
redis.options.readOnly = readOnly;
49-
debug('Change role of %s to %s', node.key, readOnly ? 'slave' : 'master')
49+
debug('Change role of %s to %s', node.key, readOnly ? 'slave' : 'master');
5050
redis[readOnly ? 'readonly' : 'readwrite']().catch(_.noop);
5151
if (readOnly) {
5252
delete this.nodes.master[node.key];
@@ -59,7 +59,14 @@ ConnectionPool.prototype.findOrCreate = function (node, readOnly) {
5959
} else {
6060
debug('Connecting to %s as %s', node.key, readOnly ? 'slave' : 'master');
6161
redis = new Redis(_.defaults({
62+
// Never try to reconnect when a node is lose,
63+
// instead, waiting for a `MOVED` error and
64+
// fetch the slots again.
6265
retryStrategy: null,
66+
// Offline queue should be enabled so that
67+
// we don't need to wait for the `ready` event
68+
// before sending commands to the node.
69+
enableOfflineQueue: true,
6370
readOnly: readOnly
6471
}, node, this.redisOptions, { lazyConnect: true }));
6572
this.nodes.all[node.key] = redis;

0 commit comments

Comments
 (0)