diff options
author | Matteo Collina <hello@matteocollina.com> | 2018-10-26 13:38:08 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2018-10-28 17:02:10 +0300 |
commit | b1e1fe4e07e24fcafa278b498291620dd61411ab (patch) | |
tree | 24c2499fb5b0129839c2c188c5fcab8f39f3236b /test | |
parent | 398418dd2619a2853b4a8b252db90fdf4cb60f7c (diff) |
stream: do not error async iterators on destroy(null)
Fixes: https://github.com/nodejs/node/issues/23890
PR-URL: https://github.com/nodejs/node/pull/23901
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-stream-readable-async-iterators.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index a9431fab816..83540de9def 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -335,11 +335,8 @@ async function tests() { readable.destroy(); - try { - await readable[Symbol.asyncIterator]().next(); - } catch (e) { - assert.strictEqual(e.code, 'ERR_STREAM_PREMATURE_CLOSE'); - } + const { done } = await readable[Symbol.asyncIterator]().next(); + assert.strictEqual(done, true); })(); await (async function() { @@ -380,6 +377,22 @@ async function tests() { for await (const b of r) { } })(); + + await (async () => { + console.log('destroy mid-stream does not error'); + const r = new Readable({ + objectMode: true, + read() { + this.push('asdf'); + this.push('hehe'); + } + }); + + // eslint-disable-next-line no-unused-vars + for await (const a of r) { + r.destroy(null); + } + })(); } // to avoid missing some tests if a promise does not resolve |