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 2a2fe8a

Browse filesBrowse files
Flarnatargos
authored andcommitted
test: fix flaky test-http2-client-upload
Wait for close event on server stream before shuting down server and client to avoid races seen on windows CI. Refs: #20750 (comment) PR-URL: #29889 Refs: #29852 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 3c63af2 commit 2a2fe8a
Copy full SHA for 2a2fe8a

File tree

Expand file treeCollapse file tree

1 file changed

+11
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-6
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http2-client-upload.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-upload.js
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,29 @@ fs.readFile(loc, common.mustCall((err, data) => {
2121
fileData = data;
2222

2323
const server = http2.createServer();
24+
let client;
25+
26+
const countdown = new Countdown(3, () => {
27+
server.close();
28+
client.close();
29+
});
2430

2531
server.on('stream', common.mustCall((stream) => {
2632
let data = Buffer.alloc(0);
2733
stream.on('data', (chunk) => data = Buffer.concat([data, chunk]));
2834
stream.on('end', common.mustCall(() => {
2935
assert.deepStrictEqual(data, fileData);
3036
}));
37+
// Waiting on close avoids spurious ECONNRESET seen in windows CI.
38+
// Not sure if this is actually a bug; more details at
39+
// https://github.com/nodejs/node/issues/20750#issuecomment-511015247
40+
stream.on('close', () => countdown.dec());
3141
stream.respond();
3242
stream.end();
3343
}));
3444

3545
server.listen(0, common.mustCall(() => {
36-
const client = http2.connect(`http://localhost:${server.address().port}`);
37-
38-
const countdown = new Countdown(2, () => {
39-
server.close();
40-
client.close();
41-
});
46+
client = http2.connect(`http://localhost:${server.address().port}`);
4247

4348
const req = client.request({ ':method': 'POST' });
4449
req.on('response', common.mustCall());

0 commit comments

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