diff --git a/test/sequential/test-http2-session-timeout.js b/test/sequential/test-http2-session-timeout.js index 5c4f047b338e9c..14a31bad9bd0fc 100644 --- a/test/sequential/test-http2-session-timeout.js +++ b/test/sequential/test-http2-session-timeout.js @@ -3,10 +3,15 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const assert = require('assert'); const http2 = require('http2'); const serverTimeout = common.platformTimeout(200); -const mustNotCall = common.mustNotCall(); + +let requests = 0; +const mustNotCall = () => { + assert.fail(`Timeout after ${requests} request(s)`); +}; const server = http2.createServer(); server.timeout = serverTimeout; @@ -32,11 +37,13 @@ server.listen(0, common.mustCall(() => { request.resume(); request.end(); + requests += 1; + request.on('end', () => { const diff = process.hrtime(startTime); const milliseconds = (diff[0] * 1e3 + diff[1] / 1e6); if (milliseconds < serverTimeout * 2) { - setImmediate(makeReq); + makeReq(); } else { server.removeListener('timeout', mustNotCall); server.close();