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(() => {