Skip to content

Commit

Permalink
fix(cluster): reconnect when failing to refresh slots cache for all n…
Browse files Browse the repository at this point in the history
…odes

Without this change it takes really a long time to identify that actually the whole cluster is down (like ~10s).
  • Loading branch information
leibale authored Mar 14, 2021
1 parent 15b090b commit 8524eea
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,7 @@ class Cluster extends EventEmitter {
this.once("close", closeListener);
this.once("close", this.handleCloseEvent.bind(this));

this.refreshSlotsCache(
function (err) {
if (err && err.message === "Failed to refresh slots cache.") {
Redis.prototype.silentEmit.call(this, "error", err);
this.connectionPool.reset([]);
}
}.bind(this)
);
this.refreshSlotsCache();
this.subscriber.start();
})
.catch((err) => {
Expand Down Expand Up @@ -519,6 +512,8 @@ class Cluster extends EventEmitter {
"Failed to refresh slots cache.",
lastNodeError
);
Redis.prototype.silentEmit.call(_this, "error", error);
_this.connectionPool.reset([]);
return wrapper(error);
}
const node = nodes[index];
Expand Down

0 comments on commit 8524eea

Please sign in to comment.