Skip to content

Commit 27c6236

Browse files
committed
Fix timeouts so that stdout/stderr activity does not keep a test running
fixes #3373
1 parent 024de32 commit 27c6236

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

lib/api.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ export default class Api extends Emittery {
221221
if (record.testFile && !timedOutWorkerFiles.has(record.testFile)) {
222222
// Debounce the timer whenever there is activity from workers that
223223
// haven't already timed out.
224-
timeoutTrigger.debounce();
224+
if (record.type !== 'worker-stderr' && record.type !== 'worker-stdout') {
225+
timeoutTrigger.debounce();
226+
}
225227
}
226228

227229
if (failFast && (record.type === 'hook-failed' || record.type === 'test-failed' || record.type === 'worker-failed')) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'ava';
2+
3+
test('timeout with console output', async t => {
4+
t.timeout(5, 'timeout despite console output');
5+
for (;;) {
6+
console.log('sorry for the noise');
7+
await new Promise(resolve => setTimeout(resolve, 1000));
8+
}
9+
});

test/test-timeouts/snapshots/test.js.md

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ Generated by [AVA](https://avajs.dev).
1818
label: 'Called with:',
1919
},
2020
]
21+
22+
## timeouts are not blocked by console output
23+
24+
> timeout despite console output
25+
26+
'timeout despite console output'
53 Bytes
Binary file not shown.

test/test-timeouts/test.js

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ test('timeout messages must be strings', async t => {
1414
t.snapshot(error.message, 'error message');
1515
t.snapshot(error.formattedDetails, 'formatted details');
1616
});
17+
18+
test('timeouts are not blocked by console output', async t => {
19+
const result = await t.throwsAsync(fixture(['console-output.js']));
20+
const error = result.stats.getError(result.stats.failed[0]);
21+
t.snapshot(error.message, 'timeout despite console output');
22+
});

0 commit comments

Comments
 (0)