Skip to content

Commit 9e3eddc

Browse files
committed
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent f4153c2 commit 9e3eddc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-stream-pipeline.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,20 @@ const { promisify } = require('util');
10481048
}));
10491049
src.push(null);
10501050
}
1051+
1052+
{
1053+
const src = new PassThrough();
1054+
const dst = pipeline(
1055+
src,
1056+
async function * (source) {
1057+
for await (const chunk of source) {
1058+
yield chunk;
1059+
}
1060+
},
1061+
common.mustCall((err) => {
1062+
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
1063+
})
1064+
);
1065+
src.push('asd');
1066+
dst.destroy();
1067+
}

0 commit comments

Comments
 (0)