diff --git a/test/parallel/test-http2-session-timeout.js b/test/sequential/test-http2-session-timeout.js similarity index 59% rename from test/parallel/test-http2-session-timeout.js rename to test/sequential/test-http2-session-timeout.js index 27cab3d8bd..a7c6184442 100644 --- a/test/parallel/test-http2-session-timeout.js +++ b/test/sequential/test-http2-session-timeout.js @@ -7,20 +7,22 @@ if (!common.hasCrypto) const h2 = require('http2'); const serverTimeout = common.platformTimeout(200); -const callTimeout = common.platformTimeout(10); +const callTimeout = common.platformTimeout(20); +const minRuns = Math.ceil(serverTimeout / callTimeout) * 2; +const mustNotCall = common.mustNotCall(); const server = h2.createServer(); server.timeout = serverTimeout; server.on('request', (req, res) => res.end()); -server.on('timeout', common.mustNotCall()); +server.on('timeout', mustNotCall); server.listen(0, common.mustCall(() => { const port = server.address().port; const url = `http://localhost:${port}`; const client = h2.connect(url); - makeReq(40); + makeReq(minRuns); function makeReq(attempts) { const request = client.request({ @@ -29,13 +31,17 @@ server.listen(0, common.mustCall(() => { ':scheme': 'http', ':authority': `localhost:${port}`, }); + request.resume(); request.end(); - if (attempts) { - setTimeout(() => makeReq(attempts - 1), callTimeout); - } else { - server.close(); - client.destroy(); - } + request.on('end', () => { + if (attempts) { + setTimeout(() => makeReq(attempts - 1), callTimeout); + } else { + server.removeListener('timeout', mustNotCall); + client.destroy(); + server.close(); + } + }); } }));