File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
packages/client/lib/client Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,23 @@ describe('Client', () => {
229
229
AbortError
230
230
) ;
231
231
} , GLOBAL . SERVERS . OPEN ) ;
232
+
233
+ testUtils . testWithClient ( 'AbortError with timeout' , client => {
234
+ const controller = new AbortController ( ) ;
235
+ controller . abort ( ) ;
236
+
237
+ return assert . rejects (
238
+ client . sendCommand ( [ 'PING' ] , {
239
+ abortSignal : controller . signal
240
+ } ) ,
241
+ AbortError
242
+ ) ;
243
+ } , {
244
+ ...GLOBAL . SERVERS . OPEN ,
245
+ clientOptions : {
246
+ commandTimeout : 50 ,
247
+ }
248
+ } ) ;
232
249
} ) ;
233
250
234
251
testUtils . testWithClient ( 'CommandTimeoutError' , async client => {
Original file line number Diff line number Diff line change @@ -737,9 +737,16 @@ export default class RedisClient<
737
737
let controller : AbortController ;
738
738
if ( this . _self . #options?. commandTimeout ) {
739
739
controller = new AbortController ( )
740
+ let abortSignal = controller . signal ;
741
+ if ( options ?. abortSignal ) {
742
+ abortSignal = AbortSignal . any ( [
743
+ abortSignal ,
744
+ options . abortSignal
745
+ ] ) ;
746
+ }
740
747
options = {
741
748
...options ,
742
- abortSignal : controller . signal
749
+ abortSignal
743
750
}
744
751
}
745
752
const promise = this . _self . #queue. addCommand < T > ( args , options ) ;
You can’t perform that action at this time.
0 commit comments