From 0185e3a46c25ab1d2c97ff72d96080e0f414750e Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sun, 22 Mar 2020 17:43:49 +0100 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/32425 Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- test/parallel/test-stream-pipeline.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 5175b7e07c53c2..191e8c8471bd1c 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -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(); +}