@@ -370,12 +370,15 @@ export default class RedisClusterSlots<
370370 . finally ( ( ) => node . connectPromise = undefined ) ;
371371 }
372372
373- nodeClient ( node : ShardNode < M , F , S , RESP , TYPE_MAPPING > ) {
374- return (
375- node . connectPromise ?? // if the node is connecting
376- node . client ?? // if the node is connected
377- this . #createNodeClient( node ) // if the not is disconnected
378- ) ;
373+ nodeClient ( node : ShardNode < M , F , S , RESP , TYPE_MAPPING > ) : Promise < RedisClientType < M , F , S , RESP , TYPE_MAPPING > > {
374+ // if the node is connecting
375+ if ( node . connectPromise )
376+ return node . connectPromise ;
377+ // if the node is connected
378+ if ( node . client )
379+ return Promise . resolve ( node . client ) ;
380+ // if the not is disconnected
381+ return this . #createNodeClient( node )
379382 }
380383
381384 #runningRediscoverPromise?: Promise < void > ;
@@ -553,10 +556,10 @@ export default class RedisClusterSlots<
553556 return this . nodeClient ( master ) ;
554557 }
555558
556- getPubSubClient ( ) {
559+ getPubSubClient ( ) : Promise < RedisClientType < M , F , S , RESP , TYPE_MAPPING > > {
557560 if ( ! this . pubSubNode ) return this . #initiatePubSubClient( ) ;
558561
559- return this . pubSubNode . connectPromise ?? this . pubSubNode . client ;
562+ return this . pubSubNode . connectPromise ?? Promise . resolve ( this . pubSubNode . client ) ;
560563 }
561564
562565 async #initiatePubSubClient( toResubscribe ?: PubSubToResubscribe ) {
@@ -602,10 +605,10 @@ export default class RedisClusterSlots<
602605 }
603606 }
604607
605- getShardedPubSubClient ( channel : string ) {
608+ getShardedPubSubClient ( channel : string ) : Promise < RedisClientType < M , F , S , RESP , TYPE_MAPPING > > {
606609 const { master } = this . slots [ calculateSlot ( channel ) ] ;
607610 if ( ! master . pubSub ) return this . #initiateShardedPubSubClient( master ) ;
608- return master . pubSub . connectPromise ?? master . pubSub . client ;
611+ return master . pubSub . connectPromise ?? Promise . resolve ( master . pubSub . client ) ;
609612 }
610613
611614 async #initiateShardedPubSubClient( master : MasterNode < M , F , S , RESP , TYPE_MAPPING > ) {
0 commit comments