summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-readable-async-iterators.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-17 10:51:38 +0200
committerMatteo Collina <hello@matteocollina.com>2019-08-23 08:58:10 +0200
commit4e188b3c63f0488be03a1f723b9b50720c76fed4 (patch)
treeb0d6f4c71fbb1a42818fb2e2cf68ca936774f7de /test/parallel/test-stream-readable-async-iterators.js
parent2fc87685d90ea9a8ad21d2f4515eaf329d71b3f1 (diff)
downloadandroid-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/parallel/test-stream-readable-async-iterators.js')
-rw-r--r--test/parallel/test-stream-readable-async-iterators.js41
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());