From 341f0c5be7d57cb293847747123a093de08152ec Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 27 Nov 2017 22:55:14 +0100 Subject: [PATCH] test: fix flaky parallel/test-http2-client-upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In parallel/test-http2-client-upload, the `client.destroy()` call could terminate the connection before all data was sent over the wire successfully. Using `client.shutdown()` removes the flakiness. Also, listen on `req.on('finish')` rather than the file stream’s `end` event, since we’re not interested in when the source stream finishes, but rather when the HTTP/2 stream finishes. PR-URL: https://github.com/nodejs/node/pull/17361 Refs: https://github.com/nodejs/node/pull/17356 Reviewed-By: James M Snell Reviewed-By: Kyle Farnung Reviewed-By: Refael Ackermann Reviewed-By: Anatoli Papirovski Reviewed-By: Jon Moss --- test/parallel/test-http2-client-upload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-client-upload.js b/test/parallel/test-http2-client-upload.js index cfba97696ce227..8fb5f369ca4cb7 100644 --- a/test/parallel/test-http2-client-upload.js +++ b/test/parallel/test-http2-client-upload.js @@ -38,7 +38,7 @@ fs.readFile(loc, common.mustCall((err, data) => { function maybeClose() { if (--remaining === 0) { server.close(); - client.destroy(); + client.shutdown(); } } @@ -47,7 +47,7 @@ fs.readFile(loc, common.mustCall((err, data) => { req.resume(); req.on('end', common.mustCall(maybeClose)); const str = fs.createReadStream(loc); - str.on('end', common.mustCall(maybeClose)); + req.on('finish', common.mustCall(maybeClose)); str.pipe(req); })); }));