summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2018-10-26 12:38:08 +0200
committerMichaƫl Zasso <targos@protonmail.com>2018-10-28 15:02:10 +0100
commitb1e1fe4e07e24fcafa278b498291620dd61411ab (patch)
tree24c2499fb5b0129839c2c188c5fcab8f39f3236b /test
parent398418dd2619a2853b4a8b252db90fdf4cb60f7c (diff)
downloadandroid-node-v8-b1e1fe4e07e24fcafa278b498291620dd61411ab.tar.gz
android-node-v8-b1e1fe4e07e24fcafa278b498291620dd61411ab.tar.bz2
android-node-v8-b1e1fe4e07e24fcafa278b498291620dd61411ab.zip
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.js23
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 a9431fab81..83540de9de 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