File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import fork from './fork.js';
16
16
import * as globs from './globs.js' ;
17
17
import isCi from './is-ci.js' ;
18
18
import { getApplicableLineNumbers } from './line-numbers.js' ;
19
+ import { setCappedTimeout } from './now-and-timers.cjs' ;
19
20
import { observeWorkerProcess } from './plugin-support/shared-workers.js' ;
20
21
import RunStatus from './run-status.js' ;
21
22
import scheduler from './scheduler.js' ;
@@ -52,7 +53,7 @@ class TimeoutTrigger {
52
53
53
54
debounce ( ) {
54
55
if ( this . timer === undefined ) {
55
- this . timer = setTimeout ( ( ) => this . trigger ( ) , this . waitMs ) ;
56
+ this . timer = setCappedTimeout ( ( ) => this . trigger ( ) , this . waitMs ) ;
56
57
} else {
57
58
this . timer . refresh ( ) ;
58
59
}
Original file line number Diff line number Diff line change @@ -3,3 +3,14 @@ const timers = require('timers');
3
3
4
4
Object . assign ( exports , timers ) ;
5
5
exports . now = Date . now ;
6
+
7
+ // Any delay larger than this value is ignored by Node.js, with a delay of `1`
8
+ // used instead. See <https://nodejs.org/api/timers.html#settimeoutcallback-delay-args>.
9
+ const MAX_DELAY = ( 2 ** 31 ) - 1 ;
10
+
11
+ function setCappedTimeout ( callback , delay ) {
12
+ const safeDelay = Math . min ( delay , MAX_DELAY ) ;
13
+ return timers . setTimeout ( callback , safeDelay ) ;
14
+ }
15
+
16
+ exports . setCappedTimeout = setCappedTimeout ;
Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ export default class Test {
405
405
406
406
this . clearTimeout ( ) ;
407
407
this . timeoutMs = ms ;
408
- this . timeoutTimer = nowAndTimers . setTimeout ( ( ) => {
408
+ this . timeoutTimer = nowAndTimers . setCappedTimeout ( ( ) => {
409
409
this . saveFirstError ( new Error ( message || 'Test timeout exceeded' ) ) ;
410
410
411
411
if ( this . finishDueToTimeout ) {
You can’t perform that action at this time.
0 commit comments