Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 26e4c58

Browse filesBrowse files
davidbenevanlucas
authored andcommitted
test: fix flaky test-http2-create-client-connect
The first group of tests makes one more connection and leave the server alive for longer. Otherwise the test is just catching that the server has closed the socket, depending on timing. This does not quite make the test pass yet, however. There are some quirks with how the http2 code handles errors which actually affect 1.0.2 as well. PR-URL: #16130 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent f952caa commit 26e4c58
Copy full SHA for 26e4c58

File tree

Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http2-create-client-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-create-client-connect.js
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Tests http2.connect()
44

55
const common = require('../common');
6+
const Countdown = require('../common/countdown');
67
if (!common.hasCrypto)
78
common.skip('missing crypto');
89
const fixtures = require('../common/fixtures');
@@ -25,13 +26,12 @@ const URL = url.URL;
2526
[{ port: port, hostname: '127.0.0.1' }, { protocol: 'http:' }]
2627
];
2728

28-
let count = items.length;
29+
const serverClose = new Countdown(items.length + 1,
30+
() => setImmediate(() => server.close()));
2931

3032
const maybeClose = common.mustCall((client) => {
3133
client.destroy();
32-
if (--count === 0) {
33-
setImmediate(() => server.close());
34-
}
34+
serverClose.dec();
3535
}, items.length);
3636

3737
items.forEach((i) => {
@@ -42,7 +42,7 @@ const URL = url.URL;
4242

4343
// Will fail because protocol does not match the server.
4444
h2.connect({ port: port, protocol: 'https:' })
45-
.on('socketError', common.mustCall());
45+
.on('socketError', common.mustCall(() => serverClose.dec()));
4646
}));
4747
}
4848

@@ -70,13 +70,12 @@ const URL = url.URL;
7070
[{ port: port, hostname: '127.0.0.1', protocol: 'https:' }, opts]
7171
];
7272

73-
let count = items.length;
73+
const serverClose = new Countdown(items.length,
74+
() => setImmediate(() => server.close()));
7475

7576
const maybeClose = common.mustCall((client) => {
7677
client.destroy();
77-
if (--count === 0) {
78-
setImmediate(() => server.close());
79-
}
78+
serverClose.dec();
8079
}, items.length);
8180

8281
items.forEach((i) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.