Description
Description
Hi,
Thanks for the great work on this library!
I believe there might be an issue with how the masters array is populated in RedisClusterSlots. Consider this scenario:
Let’s assume I have a cluster with 300 max slots. If:
-
node-1
owns slots0–100
and200–300
-
node-2
owns slots101–199
Then client.clusterSlots()
will return three entries—two of them for node-1 with different from/to ranges.
When iterating over this result to populate the masters array, node-1
appears twice. This leads to the masters
array having 3 entries instead of the expected 2 (i.e., node-1
and node-2
only once each).
Here’s a minimal example:
const cluster = createCluster(...);
await cluster.connect();
console.log(cluster.masters.length); // Outputs 3 instead of 2
Is this the expected behavior? Or should masters
deduplicate entries by host/port or id?
Thanks in advance for clarifying!
Node.js Version
v22.14.0
Redis Server Version
7.2.4
Node Redis Version
4.7.1
Platform
Linux