File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1722,23 +1722,27 @@ test('Should use retry-after header for retries (date) but date format is wrong
17221722 throwOnError : false
17231723 }
17241724 }
1725+ const minRetryDelay = dispatchOptions . retryOptions . minTimeout
17251726
17261727 server . on ( 'request' , ( req , res ) => {
17271728 switch ( counter ) {
1728- case 0 :
1729- checkpoint = Date . now ( )
1729+ case 0 : {
1730+ checkpoint = process . hrtime . bigint ( )
17301731 res . writeHead ( 429 , {
17311732 'retry-after' : 'this is not a date'
17321733 } )
17331734 res . end ( 'rate limit' )
17341735 counter ++
17351736 return
1736- case 1 :
1737+ }
1738+ case 1 : {
17371739 res . writeHead ( 200 )
17381740 res . end ( 'hello world!' )
1739- t . ok ( Date . now ( ) - checkpoint >= 1000 )
1741+ const elapsedMs = Number ( process . hrtime . bigint ( ) - checkpoint ) / 1e6
1742+ t . ok ( elapsedMs >= minRetryDelay - 100 )
17401743 counter ++
17411744 return
1745+ }
17421746 default :
17431747 t . fail ( 'unexpected request' )
17441748 }
You can’t perform that action at this time.
0 commit comments