diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js index 7882f79657f701..0ef05da1935d8c 100644 --- a/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -15,19 +15,22 @@ const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const loc = fixtures.path('person-large.jpg'); -const fn = path.join(tmpdir.path, 'http2-url-tests.js'); +const fn = path.join(tmpdir.path, 'person-large.jpg'); const server = http2.createServer(); server.on('stream', common.mustCall((stream) => { const dest = stream.pipe(fs.createWriteStream(fn)); - dest.on('finish', () => { - assert.strictEqual(fs.readFileSync(loc).length, - fs.readFileSync(fn).length); - }); - stream.respond(); - stream.end(); + stream.on('end', common.mustCall(() => { + stream.respond(); + stream.end(); + })); + + dest.on('finish', common.mustCall(() => { + assert.strictEqual(fs.readFileSync(fn).length, + fs.readFileSync(loc).length); + })); })); server.listen(common.PIPE, common.mustCall(() => {