diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-08-17 10:51:38 +0200 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2019-08-23 08:58:10 +0200 |
commit | 4e188b3c63f0488be03a1f723b9b50720c76fed4 (patch) | |
tree | b0d6f4c71fbb1a42818fb2e2cf68ca936774f7de /test | |
parent | 2fc87685d90ea9a8ad21d2f4515eaf329d71b3f1 (diff) | |
download | android-node-v8-4e188b3c63f0488be03a1f723b9b50720c76fed4.tar.gz android-node-v8-4e188b3c63f0488be03a1f723b9b50720c76fed4.tar.bz2 android-node-v8-4e188b3c63f0488be03a1f723b9b50720c76fed4.zip |
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.
PR-URL: https://github.com/nodejs/node/pull/29176
Reviewed-By: Matteo Collina <matteo.collina@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 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index 12971cb236..4a63e9fd30 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -486,5 +486,46 @@ async function tests() { } } +{ + // AsyncIterator return should end even when destroy + // does not implement the callback API. + + const r = new Readable({ + objectMode: true, + read() { + } + }); + + const originalDestroy = r.destroy; + r.destroy = (err) => { + originalDestroy.call(r, err); + }; + const it = r[Symbol.asyncIterator](); + const p = it.return(); + r.push(null); + p.then(common.mustCall()); +} + + +{ + // AsyncIterator return should not error with + // premature close. + + const r = new Readable({ + objectMode: true, + read() { + } + }); + + const originalDestroy = r.destroy; + r.destroy = (err) => { + originalDestroy.call(r, err); + }; + const it = r[Symbol.asyncIterator](); + const p = it.return(); + r.emit('close'); + p.then(common.mustCall()).catch(common.mustNotCall()); +} + // To avoid missing some tests if a promise does not resolve tests().then(common.mustCall()); |