Skip to content

Commit a40ee21

Browse files
Trotttargos
authored andcommitted
test: improve reliability in http2-session-timeout
Use `setImmediate()` instead of `setTimeout()` to improve robustness of test-http2-session-timeout. Fixes: #20628 PR-URL: #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>
1 parent d364f9c commit a40ee21

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/sequential/test-http2-session-timeout.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
6-
const h2 = require('http2');
6+
const http2 = require('http2');
77

88
const serverTimeout = common.platformTimeout(200);
9-
const callTimeout = common.platformTimeout(20);
109
const mustNotCall = common.mustNotCall();
1110

12-
const server = h2.createServer();
11+
const server = http2.createServer();
1312
server.timeout = serverTimeout;
1413

1514
server.on('request', (req, res) => res.end());
@@ -19,7 +18,7 @@ server.listen(0, common.mustCall(() => {
1918
const port = server.address().port;
2019

2120
const url = `http://localhost:${port}`;
22-
const client = h2.connect(url);
21+
const client = http2.connect(url);
2322
const startTime = process.hrtime();
2423
makeReq();
2524

@@ -37,7 +36,7 @@ server.listen(0, common.mustCall(() => {
3736
const diff = process.hrtime(startTime);
3837
const milliseconds = (diff[0] * 1e3 + diff[1] / 1e6);
3938
if (milliseconds < serverTimeout * 2) {
40-
setTimeout(makeReq, callTimeout);
39+
setImmediate(makeReq);
4140
} else {
4241
server.removeListener('timeout', mustNotCall);
4342
server.close();

0 commit comments

Comments
 (0)