From 5ea6fa711e2ab59448595d431265c2072ebc3bb1 Mon Sep 17 00:00:00 2001 From: jakecastelli Date: Tue, 17 Dec 2024 15:20:54 +1030 Subject: [PATCH] test: add coverage for pipeline co-authored-by: jazelly PR-URL: https://github.com/nodejs/node/pull/56278 Reviewed-By: Matteo Collina --- test/parallel/test-stream-pipeline.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 2ee323a934606e..2bbdabe9d347b1 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1723,3 +1723,30 @@ tmpdir.refresh(); }); src.destroy(new Error('problem')); } + +{ + async function* myAsyncGenerator(ag) { + for await (const data of ag) { + yield data; + } + } + + const duplexStream = Duplex.from(myAsyncGenerator); + + const r = new Readable({ + read() { + this.push('data1\n'); + throw new Error('booom'); + }, + }); + + const w = new Writable({ + write(chunk, encoding, callback) { + callback(); + }, + }); + + pipeline(r, duplexStream, w, common.mustCall((err) => { + assert.deepStrictEqual(err, new Error('booom')); + })); +}