Skip to content

Commit

Permalink
test: fix flaky parallel/test-http2-client-upload
Browse files Browse the repository at this point in the history
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: #17361
Refs: #17356
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information
addaleax authored and MylesBorins committed Dec 11, 2017
1 parent eddf7d9 commit 17f39b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-http2-client-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fs.readFile(loc, common.mustCall((err, data) => {
function maybeClose() {
if (--remaining === 0) {
server.close();
client.destroy();
client.shutdown();
}
}

Expand All @@ -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);
}));
}));

0 comments on commit 17f39b2

Please sign in to comment.