#3454·ava

Blocking tests don't cause tests with timeout to fail

Author: ericcornelissenCreated May 30, 2026Updated Jun 6, 2026
Labelsneeds triage

When a test is slow in a blocking fashion, AVA's timeout does not apply. A blocking test can take 10s and pass with a 5s timeout. The following test suite demonstrates the asymmetry between blocking and non-blocking tests (with a 10ms runtime and 5ms timeout instead):

javascript
// minimal-ava.js

var test = require('ava').default;

test('blocking', function (t) {
	t.timeout(5);
	var start = Date.now();
	while (Date.now() < start + 10) { /* Busy-wait to block the event loop */ }
	t.pass("slow success");
});

test('async', function (t) {
	t.timeout(5);
	return new Promise(function (resolve) {
		setTimeout(function () {
			t.pass("slow success");
			resolve();
		}, 10);
	});
});

If you run it (using an up-to-date version of Node.js and AVA) the first test will pass and the other will fail:

bash
$ node --version
v26.0.0

$ npm ls ava | grep ava
-- [email protected]

$ npx ava minimal-ava.js

  ✔ blocking
  ✘ [fail]: async Test timeout exceeded
  ─

  async

  Error: Test timeout exceeded

  Error: Test timeout exceeded
      at Timeout.<anonymous> (file://.../node_modules/ava/lib/test.js:443:24)
      at listOnTimeout (node:internal/timers:605:17)
      at process.processTimers (node:internal/timers:541:7)

  ─

  1 test failed

For completeness, when using the --timeout option, the timeout does apply to the blocking test case (though somewhat surprisingly I need something like --timeout=120 for the above test file not to exit "early" with ✘ Timed out while running tests).

I would expect all these tests to fail. As a point of comparison Mocha does behave this way (Mocha PoC) whereas tape has the same limitation as AVA (tape PoC).

If AVA should indeed fail in both cases, I believe the fix implementation can be based off of my assert-time package (which is also MIT licensed, so the code can easily be used for AVA).

I (somewhat surprisingly) did not find an existing issue for this problem. The closest issues seems to https://github.com/avajs/ava/issues/3078/https://github.com/avajs/ava/discussions/3085.