Skip to content

Commit b822bd5

Browse files
committed
Don't restart timeout timer when receiving events from timed out workers
It can take longer for workers to exit than the timeout period, in which case restarting the timeout timer just causes it to fire again.
1 parent 442a9fa commit b822bd5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

api.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Api extends Emittery {
5252
const failFast = apiOptions.failFast === true;
5353
let bailed = false;
5454
const pendingWorkers = new Set();
55+
const timedOutWorkerFiles = new Set();
5556
let restartTimer;
5657
if (apiOptions.timeout) {
5758
const timeout = ms(apiOptions.timeout);
@@ -64,6 +65,7 @@ class Api extends Emittery {
6465
}
6566

6667
for (const worker of pendingWorkers) {
68+
timedOutWorkerFiles.add(worker.file);
6769
worker.exit();
6870
}
6971

@@ -98,8 +100,11 @@ class Api extends Emittery {
98100
}
99101

100102
runStatus.on('stateChange', record => {
101-
// Restart the timer whenever there is activity.
102-
restartTimer();
103+
if (record.testFile && !timedOutWorkerFiles.has(record.testFile)) {
104+
// Restart the timer whenever there is activity from workers that
105+
// haven't already timed out.
106+
restartTimer();
107+
}
103108

104109
if (failFast && (record.type === 'hook-failed' || record.type === 'test-failed' || record.type === 'worker-failed')) {
105110
// Prevent new test files from running once a test has failed.

lib/fork.js

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module.exports = (file, opts, execArgv) => {
120120
return emitter.on('stateChange', listener);
121121
},
122122

123+
file,
123124
promise
124125
};
125126
};

profile.js

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ babelConfigHelper.build(process.cwd(), cacheDir, babelConfigHelper.validate(conf
110110

111111
const runStatus = new RunStatus([file]);
112112
runStatus.observeWorker({
113+
file,
113114
onStateChange(listener) {
114115
const emit = evt => listener(Object.assign(evt, {testFile: file}));
115116
process.send = data => {

0 commit comments

Comments
 (0)