Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/client/lib/cluster/cluster-slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ export default class RedisClusterSlots<
}

async #discover(rootNode: RedisClusterClientOptions) {
this.#resetSlots();
try {
const addressesInUse = new Set<string>(),
promises: Array<Promise<unknown>> = [],
eagerConnect = this.#options.minimizeConnections !== true;

for (const { from, to, master, replicas } of await this.#getShards(rootNode)) {
const shards = await this.#getShards(rootNode);
this.#resetSlots(); // Reset slots AFTER shards have been fetched to prevent a race condition

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regressed when b2d35c5 landed.

Is it possible to add a test to prevent further regressions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see an easy way to test it..
I'll merge the PR as is for now, and we can add the test in another PR.. :)

for (const { from, to, master, replicas } of shards) {
const shard: Shard<M, F, S, RESP, TYPE_MAPPING> = {
master: this.#initiateSlotNode(master, false, eagerConnect, addressesInUse, promises)
};
Expand Down