File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,9 @@ export class Ky {
297297 }
298298 }
299299
300- return Math . min ( this . #options. retry . backoffLimit , jitteredDelay ) ;
300+ // Handle undefined backoffLimit by treating it as no limit (Infinity)
301+ const backoffLimit = this . #options. retry . backoffLimit ?? Number . POSITIVE_INFINITY ;
302+ return Math . min ( backoffLimit , jitteredDelay ) ;
301303 }
302304
303305 async #calculateRetryDelay( error : unknown ) {
Original file line number Diff line number Diff line change @@ -631,6 +631,41 @@ test('respect maximum backoffLimit', async t => {
631631 await server . close ( ) ;
632632} ) ;
633633
634+ test ( 'backoffLimit: undefined treats as no limit (Infinity)' , async t => {
635+ const retryCount = 4 ;
636+ let requestCount = 0 ;
637+
638+ const server = await createHttpTestServer ( ) ;
639+ server . get ( '/' , ( _request , response ) => {
640+ requestCount ++ ;
641+
642+ if ( requestCount === retryCount + 1 ) {
643+ response . end ( fixture ) ;
644+ } else {
645+ response . sendStatus ( 500 ) ;
646+ }
647+ } ) ;
648+
649+ // When backoffLimit is undefined, it should behave the same as no limit
650+ // (i.e., delays should not be clamped, same as default behavior)
651+ await withPerformance ( {
652+ t,
653+ expectedDuration : 300 + 600 + 1200 + 2400 ,
654+ async test ( ) {
655+ t . is ( await ky ( server . url , {
656+ retry : {
657+ limit : retryCount ,
658+ backoffLimit : undefined ,
659+ } ,
660+ } ) . text ( ) , fixture ) ;
661+ } ,
662+ } ) ;
663+
664+ t . is ( requestCount , 5 ) ;
665+
666+ await server . close ( ) ;
667+ } ) ;
668+
634669test ( 'respect custom retry.delay' , async t => {
635670 const retryCount = 4 ;
636671 let requestCount = 0 ;
You can’t perform that action at this time.
0 commit comments