summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-07-29 19:26:27 -0700
committerRich Trott <rtrott@gmail.com>2018-08-01 15:18:44 -0700
commitd2ffcac55db928e3b525c558259f69142521d435 (patch)
tree3f88c656274f3adc90b8f66ce3d5094967694fab /test
parent9aebcc2b85720cccda1b6e50c337d8cde214bf52 (diff)
downloadandroid-node-v8-d2ffcac55db928e3b525c558259f69142521d435.tar.gz
android-node-v8-d2ffcac55db928e3b525c558259f69142521d435.tar.bz2
android-node-v8-d2ffcac55db928e3b525c558259f69142521d435.zip
test: improve reliability in http2-session-timeout
Use `setImmediate()` instead of `setTimeout()` to improve robustness of test-http2-session-timeout. Fixes: https://github.com/nodejs/node/issues/20628 PR-URL: https://github.com/nodejs/node/pull/22026 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/sequential/test-http2-session-timeout.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/test/sequential/test-http2-session-timeout.js b/test/sequential/test-http2-session-timeout.js
index 48e98998c7..5c4f047b33 100644
--- a/test/sequential/test-http2-session-timeout.js
+++ b/test/sequential/test-http2-session-timeout.js
@@ -3,13 +3,12 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const h2 = require('http2');
+const http2 = require('http2');
const serverTimeout = common.platformTimeout(200);
-const callTimeout = common.platformTimeout(20);
const mustNotCall = common.mustNotCall();
-const server = h2.createServer();
+const server = http2.createServer();
server.timeout = serverTimeout;
server.on('request', (req, res) => res.end());
@@ -19,7 +18,7 @@ server.listen(0, common.mustCall(() => {
const port = server.address().port;
const url = `http://localhost:${port}`;
- const client = h2.connect(url);
+ const client = http2.connect(url);
const startTime = process.hrtime();
makeReq();
@@ -37,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) {
- setTimeout(makeReq, callTimeout);
+ setImmediate(makeReq);
} else {
server.removeListener('timeout', mustNotCall);
server.close();