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 <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
constcommon=require('../common');
44
if(!common.hasCrypto)
55
common.skip('missing crypto');
6-
consth2=require('http2');
6+
consthttp2=require('http2');
77

88
constserverTimeout=common.platformTimeout(200);
9-
constcallTimeout=common.platformTimeout(20);
109
constmustNotCall=common.mustNotCall();
1110

12-
constserver=h2.createServer();
11+
constserver=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
constport=server.address().port;
2019

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

@@ -37,7 +36,7 @@ server.listen(0, common.mustCall(() =>{
3736
constdiff=process.hrtime(startTime);
3837
constmilliseconds=(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)