diff --git a/lib/cluster/index.ts b/lib/cluster/index.ts index 914cb87f..86bdae5f 100644 --- a/lib/cluster/index.ts +++ b/lib/cluster/index.ts @@ -266,7 +266,14 @@ class Cluster extends EventEmitter { this.once("close", closeListener); this.once("close", this.handleCloseEvent.bind(this)); - this.refreshSlotsCache(); + 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.subscriber.start(); }) .catch((err) => { @@ -513,8 +520,6 @@ 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];