Skip to content

Commit

Permalink
stream: add pipeline test for destroy of returned stream
Browse files Browse the repository at this point in the history
Adds a test to ensure that destroying the returned stream
of pipeline will cause a premature close error.

PR-URL: #32425
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
ronag authored and MylesBorins committed Mar 25, 2020
1 parent b5e4adf commit 0185e3a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,20 @@ const { promisify } = require('util');
}));
src.push(null);
}

{
const src = new PassThrough();
const dst = pipeline(
src,
async function * (source) {
for await (const chunk of source) {
yield chunk;
}
},
common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
})
);
src.push('asd');
dst.destroy();
}

0 comments on commit 0185e3a

Please sign in to comment.