Skip to content

Commit

Permalink
test: deflake http2-pipe-named-pipe
Browse files Browse the repository at this point in the history
Wait for all data to be read before sending the response and closing
the client.

Fixes: #40277

PR-URL: #40842
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Adrian Estrada <edsadr@gmail.com>
  • Loading branch information
lpinca authored and nodejs-github-bot committed Nov 21, 2021
1 parent 2a8576d commit 4873870
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/parallel/test-http2-pipe-named-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const server = http2.createServer();
server.on('stream', common.mustCall((stream) => {
const dest = stream.pipe(fs.createWriteStream(fn));

dest.on('finish', () => {
stream.on('end', common.mustCall(() => {
stream.respond();
stream.end();
}));

dest.on('finish', common.mustCall(() => {
assert.strictEqual(fs.readFileSync(loc).length,
fs.readFileSync(fn).length);
});
stream.respond();
stream.end();
}));
}));

server.listen(common.PIPE, common.mustCall(() => {
Expand Down

0 comments on commit 4873870

Please sign in to comment.