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 <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
ronag committed Mar 25, 2020
1 parent f4153c2 commit 9e3eddc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-stream-pipeline.js
Expand Up @@ -1048,3 +1048,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 9e3eddc

Please sign in to comment.