GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: fix flaky test-http2-session-timeout · nodejs/node@1fbdf47

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/sequential
    • test-http2-session-timeout.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎…t/parallel/test-http2-session-timeout.js‎ ‎…sequential/test-http2-session-timeout.js‎test/parallel/test-http2-session-timeout.js renamed to test/sequential/test-http2-session-timeout.js test/parallel/test-http2-session-timeout.js renamed to test/sequential/test-http2-session-timeout.js

Copy file name to clipboardExpand all lines: test/sequential/test-http2-session-timeout.js
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ if (!common.hasCrypto)
77
const h2 = require('http2');
88

99
const serverTimeout = common.platformTimeout(200);
10-
const callTimeout = common.platformTimeout(10);
10+
const callTimeout = common.platformTimeout(20);
11+
const minRuns = Math.ceil(serverTimeout / callTimeout) * 2;
12+
const mustNotCall = common.mustNotCall();
1113

1214
const server = h2.createServer();
1315
server.timeout = serverTimeout;
1416

1517
server.on('request', (req, res) => res.end());
16-
server.on('timeout', common.mustNotCall());
18+
server.on('timeout', mustNotCall);
1719

1820
server.listen(0, common.mustCall(() => {
1921
const port = server.address().port;
2022

2123
const url = `http://localhost:${port}`;
2224
const client = h2.connect(url);
23-
makeReq(40);
25+
makeReq(minRuns);
2426

2527
function makeReq(attempts) {
2628
const request = client.request({
@@ -29,13 +31,17 @@ server.listen(0, common.mustCall(() => {
2931
':scheme': 'http',
3032
':authority': `localhost:${port}`,
3133
});
34+
request.resume();
3235
request.end();
3336

34-
if (attempts) {
35-
setTimeout(() => makeReq(attempts - 1), callTimeout);
36-
} else {
37-
server.close();
38-
client.destroy();
39-
}
37+
request.on('end', () => {
38+
if (attempts) {
39+
setTimeout(() => makeReq(attempts - 1), callTimeout);
40+
} else {
41+
server.removeListener('timeout', mustNotCall);
42+
client.destroy();
43+
server.close();
44+
}
45+
});
4046
}
4147
}));

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.