1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Fix race condition when slots are re-calculated (#2731)

This commit is contained in:
jjsimps
2024-05-16 12:17:32 -05:00
committed by GitHub
parent dbf8f59a47
commit bfa803fa55

View File

@@ -158,13 +158,13 @@ export default class RedisClusterSlots<
}
async #discover(rootNode?: RedisClusterClientOptions) {
this.#resetSlots();
const addressesInUse = new Set<string>();
try {
const shards = await this.#getShards(rootNode),
promises: Array<Promise<unknown>> = [],
eagerConnect = this.#options.minimizeConnections !== true;
this.#resetSlots();
for (const { from, to, master, replicas } of shards) {
const shard: Shard<M, F, S> = {
master: this.#initiateSlotNode(master, false, eagerConnect, addressesInUse, promises)