@@ -460,7 +460,7 @@ export default class RedisClient<
460
460
) ;
461
461
} else if ( ! this . #socket. isReady && this . #options?. disableOfflineQueue ) {
462
462
return Promise . reject ( new ClientOfflineError ( ) ) ;
463
- }
463
+ }
464
464
465
465
const promise = this . #queue. addCommand < T > ( args , options ) ;
466
466
this . #tick( ) ;
@@ -725,11 +725,14 @@ export default class RedisClient<
725
725
return Promise . reject ( new ClientClosedError ( ) ) ;
726
726
}
727
727
728
- const promise = Promise . all (
729
- commands . map ( ( { args } ) => {
730
- return this . #queue. addCommand ( args , { chainId } ) ;
731
- } )
732
- ) ;
728
+ const promise = chainId ?
729
+ // if `chainId` has a value, it's a `MULTI` (and not "pipeline") - need to add the `MULTI` and `EXEC` commands
730
+ Promise . all ( [
731
+ this . #queue. addCommand ( [ 'MULTI' ] , { chainId } ) ,
732
+ this . #addMultiCommands( commands , chainId ) ,
733
+ this . #queue. addCommand ( [ 'EXEC' ] , { chainId } )
734
+ ] ) :
735
+ this . #addMultiCommands( commands ) ;
733
736
734
737
this . #tick( ) ;
735
738
@@ -742,6 +745,12 @@ export default class RedisClient<
742
745
return results ;
743
746
}
744
747
748
+ #addMultiCommands( commands : Array < RedisMultiQueuedCommand > , chainId ?: symbol ) {
749
+ return Promise . all (
750
+ commands . map ( ( { args } ) => this . #queue. addCommand ( args , { chainId } ) )
751
+ ) ;
752
+ }
753
+
745
754
async * scanIterator ( options ?: ScanCommandOptions ) : AsyncIterable < string > {
746
755
let cursor = 0 ;
747
756
do {
0 commit comments