From 158c64cfe5765d3b4b61bde2de716431d83a75cd Mon Sep 17 00:00:00 2001 From: Martin Slota Date: Mon, 10 Jun 2024 13:59:56 +0200 Subject: [PATCH] Do not fail when retrieving a node by non-existing key Signed-off-by: Martin Slota --- lib/cluster/ConnectionPool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cluster/ConnectionPool.ts b/lib/cluster/ConnectionPool.ts index dea1be1..5a117ba 100644 --- a/lib/cluster/ConnectionPool.ts +++ b/lib/cluster/ConnectionPool.ts @@ -33,7 +33,7 @@ export default class ConnectionPool extends EventEmitter { } getInstanceByKey(key: NodeKey): Redis { - return this.nodeRecords.all[key].redis; + return this.nodeRecords.all[key]?.redis; } getSampleInstance(role: NodeRole): Redis {