From f3f1aec0962f988c9c04931e58fe95802f426207 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sun, 30 Jul 2023 17:03:01 +0100 Subject: [PATCH 1/2] test: test pipeline `end` on transform streams Add test that confirms that `stream.promises.pipeline(source, transform, dest, {end: false});` only skips ending the destination stream. `{end: false}` should still end any transform streams. PR-URL: https://github.com/nodejs/node/pull/48970 Reviewed-By: Luigi Pinca --- test/parallel/test-stream-pipeline.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 915a035264c7a7..8237fff33b3ac8 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1476,10 +1476,14 @@ const tsp = require('timers/promises'); }); const duplex = new PassThrough(); + const transform = new PassThrough(); read.push(null); - await pipelinePromise(read, duplex, { end: false }); + await pipelinePromise(read, transform, duplex, { end: false }); + + assert.strictEqual(transform.destroyed, true); + assert.strictEqual(transform.writableEnded, true); assert.strictEqual(duplex.destroyed, false); assert.strictEqual(duplex.writableEnded, false); From ca2f874fe30ee76d799e62a1d9bdd885cee46711 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sun, 30 Jul 2023 17:12:50 +0100 Subject: [PATCH 2/2] doc: document pipeline with `end` option There is currently no documentation about what the `end` option in `stream.promises.pipeline` does. Refs: https://github.com/nodejs/node/pull/40886 Refs: https://github.com/nodejs/node/issues/34805#issuecomment-1345655205 Fixes: https://github.com/nodejs/node/issues/45821 PR-URL: https://github.com/nodejs/node/pull/48970 Reviewed-By: Luigi Pinca --- doc/api/stream.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 808e7a6b8f2634..42885b48c74a27 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -65,6 +65,15 @@ or `require('node:stream').promises`. * `streams` {Stream\[]|Iterable\[]|AsyncIterable\[]|Function\[]} @@ -76,9 +85,11 @@ added: v15.0.0 * `destination` {Stream|Function} * `source` {AsyncIterable} * Returns: {Promise|AsyncIterable} -* `options` {Object} +* `options` {Object} Pipeline options * `signal` {AbortSignal} - * `end` {boolean} + * `end` {boolean} End the destination stream when the source stream ends. + Transform streams are always ended, even if this value is `false`. + **Default:** `true`. * Returns: {Promise} Fulfills when the pipeline is complete. ```cjs