From a64571d0437e63a33cac90710931621016020a39 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 24 Sep 2018 05:54:57 -0700 Subject: [PATCH 1/2] test: remove setImmediate from timeout test In test-http2-session-timeout, setImmediate() is used to wrap makeReq(). makeReq() is asynchronous and setImmediate() is not necessary. --- test/sequential/test-http2-session-timeout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-http2-session-timeout.js b/test/sequential/test-http2-session-timeout.js index 5c4f047b338e9c..9f0c8cd4d003c8 100644 --- a/test/sequential/test-http2-session-timeout.js +++ b/test/sequential/test-http2-session-timeout.js @@ -36,7 +36,7 @@ server.listen(0, common.mustCall(() => { 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(); From d8598aaeb83371e845374f66e2592215d81e1abc Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 24 Sep 2018 06:11:12 -0700 Subject: [PATCH 2/2] test: improve debugging information for http2 test In test-http2-session-timeout, provide the number of requests that occurred when the test fails. --- test/sequential/test-http2-session-timeout.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/sequential/test-http2-session-timeout.js b/test/sequential/test-http2-session-timeout.js index 9f0c8cd4d003c8..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,6 +37,8 @@ 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);