Skip to content

Commit bfa803f

Browse files
authored
Fix race condition when slots are re-calculated (#2731)
1 parent dbf8f59 commit bfa803f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/client/lib/cluster/cluster-slots.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ export default class RedisClusterSlots<
158158
}
159159

160160
async #discover(rootNode?: RedisClusterClientOptions) {
161-
this.#resetSlots();
162161
const addressesInUse = new Set<string>();
163162

164163
try {
165164
const shards = await this.#getShards(rootNode),
166165
promises: Array<Promise<unknown>> = [],
167166
eagerConnect = this.#options.minimizeConnections !== true;
167+
this.#resetSlots();
168168
for (const { from, to, master, replicas } of shards) {
169169
const shard: Shard<M, F, S> = {
170170
master: this.#initiateSlotNode(master, false, eagerConnect, addressesInUse, promises)

0 commit comments

Comments
 (0)