From 85ab527f7217f91e4f481c3c145c5ab833c3301b Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Tue, 8 Oct 2019 20:26:26 +0200 Subject: [PATCH 1/2] 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: https://github.com/nodejs/node/issues/20750#issuecomment-511015247 --- test/parallel/test-http2-client-upload.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-http2-client-upload.js b/test/parallel/test-http2-client-upload.js index 78c6d47cbb4f44..5f8e5158bb9a43 100644 --- a/test/parallel/test-http2-client-upload.js +++ b/test/parallel/test-http2-client-upload.js @@ -21,6 +21,12 @@ fs.readFile(loc, common.mustCall((err, data) => { fileData = data; const server = http2.createServer(); + let client; + + const countdown = new Countdown(3, () => { + server.close(); + client.close(); + }); server.on('stream', common.mustCall((stream) => { let data = Buffer.alloc(0); @@ -28,17 +34,16 @@ fs.readFile(loc, common.mustCall((err, data) => { stream.on('end', common.mustCall(() => { assert.deepStrictEqual(data, fileData); })); + // Waiting on close avoids sprious ECONNRESET seen in windows CI. + // Not sure if this is actually a bug; more details at + // https://github.com/nodejs/node/issues/20750#issuecomment-511015247 + stream.on('close', () => countdown.dec()); stream.respond(); stream.end(); })); server.listen(0, common.mustCall(() => { - const client = http2.connect(`http://localhost:${server.address().port}`); - - const countdown = new Countdown(2, () => { - server.close(); - client.close(); - }); + client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST' }); req.on('response', common.mustCall()); From 10189a58fbf028aaf174c9c88d92227a7f653512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Tue, 8 Oct 2019 21:45:14 +0200 Subject: [PATCH 2/2] Update test/parallel/test-http2-client-upload.js Co-Authored-By: Anna Henningsen --- test/parallel/test-http2-client-upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http2-client-upload.js b/test/parallel/test-http2-client-upload.js index 5f8e5158bb9a43..c5b052d2fec702 100644 --- a/test/parallel/test-http2-client-upload.js +++ b/test/parallel/test-http2-client-upload.js @@ -34,7 +34,7 @@ fs.readFile(loc, common.mustCall((err, data) => { stream.on('end', common.mustCall(() => { assert.deepStrictEqual(data, fileData); })); - // Waiting on close avoids sprious ECONNRESET seen in windows CI. + // Waiting on close avoids spurious ECONNRESET seen in windows CI. // Not sure if this is actually a bug; more details at // https://github.com/nodejs/node/issues/20750#issuecomment-511015247 stream.on('close', () => countdown.dec());