From bfa803fa55e336301eceaa25ded9f19cb9678b6b Mon Sep 17 00:00:00 2001 From: jjsimps <98552694+jjsimps@users.noreply.github.com> Date: Thu, 16 May 2024 12:17:32 -0500 Subject: [PATCH] Fix race condition when slots are re-calculated (#2731) --- packages/client/lib/cluster/cluster-slots.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/lib/cluster/cluster-slots.ts b/packages/client/lib/cluster/cluster-slots.ts index b1cc49b4c8..489ded4854 100644 --- a/packages/client/lib/cluster/cluster-slots.ts +++ b/packages/client/lib/cluster/cluster-slots.ts @@ -158,13 +158,13 @@ export default class RedisClusterSlots< } async #discover(rootNode?: RedisClusterClientOptions) { - this.#resetSlots(); const addressesInUse = new Set(); try { const shards = await this.#getShards(rootNode), promises: Array> = [], eagerConnect = this.#options.minimizeConnections !== true; + this.#resetSlots(); for (const { from, to, master, replicas } of shards) { const shard: Shard = { master: this.#initiateSlotNode(master, false, eagerConnect, addressesInUse, promises)