File tree 1 file changed +7
-1
lines changed
lib/internal/test_runner/mock
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ let kResistStopPropagation;
48
48
let kMock ;
49
49
// Initial epoch to which #now should be set to
50
50
const kInitialEpoch = 0 ;
51
+ /** @see lib/internal/timers.js#TIMEOUT_MAX */
52
+ const TIMEOUT_MAX = 2 ** 31 - 1 ;
51
53
52
54
function compareTimersLists ( a , b ) {
53
55
return ( a . runAt - b . runAt ) || ( a . id - b . id ) ;
@@ -288,6 +290,10 @@ class MockTimers {
288
290
}
289
291
290
292
#createTimer( isInterval , callback , delay , ...args ) {
293
+ if ( delay > TIMEOUT_MAX ) {
294
+ delay = 1 ;
295
+ }
296
+
291
297
const timerId = this . #currentTimer++ ;
292
298
const opts = {
293
299
__proto__ : null ,
@@ -297,7 +303,7 @@ class MockTimers {
297
303
interval : isInterval ? delay : undefined ,
298
304
args,
299
305
} ;
300
-
306
+
301
307
const timer = new Timeout ( opts ) ;
302
308
this . #executionQueue. insert ( timer ) ;
303
309
return timer ;
You can’t perform that action at this time.
0 commit comments