From 48eb663b8bbc9eed49e5b3f6779863aaf7026aa1 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 23 Aug 2021 18:41:19 +0200 Subject: [PATCH] fixup --- lib/internal/streams/duplexify.js | 4 +++- test/parallel/test-stream-pipeline.js | 33 --------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/lib/internal/streams/duplexify.js b/lib/internal/streams/duplexify.js index e47bc0e413dc69..cbcbf1fd69cc3b 100644 --- a/lib/internal/streams/duplexify.js +++ b/lib/internal/streams/duplexify.js @@ -206,15 +206,17 @@ module.exports = function duplexify(body, name) { function fromAsyncGen(fn) { let { promise, resolve } = createDeferredPromise(); const ac = new AbortController(); + const signal = ac.signal; const value = fn(async function*() { while (true) { const { chunk, done, cb } = await promise; process.nextTick(cb); if (done) return; + if (signal.aborted) throw new AbortError(); yield chunk; ({ promise, resolve } = createDeferredPromise()); } - }(), { signal: ac.signal }); + }(), { signal }); return { value, diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 3bfd4ea4e59bc7..4b0f11ea41218a 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1390,39 +1390,6 @@ const tsp = require('timers/promises'); })); } -{ - const writableLike = new Stream(); - writableLike.writableNeedDrain = true; - - pipeline( - async function *() {}, - writableLike, - common.mustCall((err) => { - assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE'); - }) - ); - - writableLike.emit('close'); -} - -{ - const writableLike = new Stream(); - writableLike.write = () => false; - - pipeline( - async function *() { - yield null; - yield null; - }, - writableLike, - common.mustCall((err) => { - assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE'); - }) - ); - - writableLike.emit('close'); -} - { const ac = new AbortController(); const signal = ac.signal;