Skip to content

Commit 0185e3a

Browse files
ronagMylesBorins
authored andcommitted
stream: add pipeline test for destroy of returned stream
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>
1 parent b5e4adf commit 0185e3a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-stream-pipeline.js

+17
Original file line numberDiff line numberDiff line change
@@ -1032,3 +1032,20 @@ const { promisify } = require('util');
10321032
}));
10331033
src.push(null);
10341034
}
1035+
1036+
{
1037+
const src = new PassThrough();
1038+
const dst = pipeline(
1039+
src,
1040+
async function * (source) {
1041+
for await (const chunk of source) {
1042+
yield chunk;
1043+
}
1044+
},
1045+
common.mustCall((err) => {
1046+
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
1047+
})
1048+
);
1049+
src.push('asd');
1050+
dst.destroy();
1051+
}

0 commit comments

Comments
 (0)