Skip to content

Commit fa677ca

Browse files
FlarnaBethGriggs
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 <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f71b09f commit fa677ca

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines 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
constserver=http2.createServer();
24+
letclient;
25+
26+
constcountdown=newCountdown(3,()=>{
27+
server.close();
28+
client.close();
29+
});
2430

2531
server.on('stream',common.mustCall((stream)=>{
2632
letdata=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-
constclient=http2.connect(`http://localhost:${server.address().port}`);
37-
38-
constcountdown=newCountdown(2,()=>{
39-
server.close();
40-
client.close();
41-
});
46+
client=http2.connect(`http://localhost:${server.address().port}`);
4247

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

0 commit comments

Comments
(0)