From af60bb082d20a32de1348f049507e6ea8862397f Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Sat, 19 Mar 2022 15:10:07 +0800 Subject: [PATCH] fix: pipeline fails when cluster is not ready Closes #1460 --- lib/Pipeline.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Pipeline.ts b/lib/Pipeline.ts index 2406dc6a..9e887b9d 100644 --- a/lib/Pipeline.ts +++ b/lib/Pipeline.ts @@ -263,9 +263,15 @@ Pipeline.prototype.exec = function (callback: Callback): Promise> { // Wait for the cluster to be connected, since we need nodes information before continuing if (this.isCluster && !this.redis.slots.length) { if (this.redis.status === "wait") this.redis.connect().catch(noop); + + if (callback && !this.nodeifiedPromise) { + this.nodeifiedPromise = true; + asCallback(this.promise, callback); + } + this.redis.delayUntilReady((err) => { if (err) { - callback(err); + this.reject(err); return; }