diff --git a/lib/cluster/index.ts b/lib/cluster/index.ts index a046c3b6..b8bdad00 100644 --- a/lib/cluster/index.ts +++ b/lib/cluster/index.ts @@ -122,7 +122,10 @@ class Cluster extends Commander { super(); EventEmitter.call(this); - this.startupNodes = startupNodes; + this.startupNodes = startupNodes + ?.map((node) => (typeof node === 'string' ? node.split(',') : [node])) + .flat(); + this.options = defaults({}, options, DEFAULT_CLUSTER_OPTIONS, this.options); if (this.options.shardedSubscribers == true) diff --git a/test/functional/cluster/connect.ts b/test/functional/cluster/connect.ts index a2346f23..783bc53c 100644 --- a/test/functional/cluster/connect.ts +++ b/test/functional/cluster/connect.ts @@ -119,6 +119,17 @@ describe("cluster:connect", () => { }); }); + it("should support url schema with mutiple nodes", (done) => { + const node = new MockServer(30001); + + const cluster = new Cluster([30002, "127.0.0.4:30001", { host:"127.0.0.3", port: 30001 }, "redis://127.0.0.2:30001,127.0.0.1:30001"]); + + node.once("connect", () => { + cluster.disconnect(); + done(); + }); + }); + it("should support a single port", (done) => { const node = new MockServer(30001);