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 @@ -263,6 +263,23 @@ describe('Client', () => {
263
263
AbortError
264
264
) ;
265
265
} , GLOBAL . SERVERS . OPEN ) ;
266
+
267
+ testUtils . testWithClient ( 'AbortError with timeout' , client => {
268
+ const controller = new AbortController ( ) ;
269
+ controller . abort ( ) ;
270
+
271
+ return assert . rejects (
272
+ client . sendCommand ( [ 'PING' ] , {
273
+ abortSignal : controller . signal
274
+ } ) ,
275
+ AbortError
276
+ ) ;
277
+ } , {
278
+ ...GLOBAL . SERVERS . OPEN ,
279
+ clientOptions : {
280
+ commandTimeout : 50 ,
281
+ }
282
+ } ) ;
266
283
} ) ;
267
284
268
285
testUtils . testWithClient ( 'CommandTimeoutError' , async client => {
Original file line number Diff line number Diff line change @@ -896,9 +896,16 @@ export default class RedisClient<
896
896
let controller : AbortController ;
897
897
if ( this . _self . #options?. commandTimeout ) {
898
898
controller = new AbortController ( )
899
+ let abortSignal = controller . signal ;
900
+ if ( options ?. abortSignal ) {
901
+ abortSignal = AbortSignal . any ( [
902
+ abortSignal ,
903
+ options . abortSignal
904
+ ] ) ;
905
+ }
899
906
options = {
900
907
...options ,
901
- abortSignal : controller . signal
908
+ abortSignal
902
909
}
903
910
}
904
911
const promise = this . _self . #queue. addCommand < T > ( args , options ) ;
You can’t perform that action at this time.
0 commit comments