From b190b0e77b1ed60b97d6d37ee227aae0f148e31d Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Wed, 17 Nov 2021 20:18:10 +0100 Subject: [PATCH] test: deflake http2-pipe-named-pipe Wait for all data to be read before sending the response and closing the client. Fixes: https://github.com/nodejs/node/issues/40277 PR-URL: https://github.com/nodejs/node/pull/40842 Reviewed-By: Robert Nagy Reviewed-By: Adrian Estrada --- test/parallel/test-http2-pipe-named-pipe.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js index 5d4f2caadb5e53..226ae80932a65c 100644 --- a/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -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(() => {