summaryrefslogtreecommitdiff
path: root/test/parallel/test-readable-from.js
diff options
context:
space:
mode:
authorBenjamin Gruenbaum <benjamingr@gmail.com>2021-01-31 17:22:28 +0200
committerBenjamin Gruenbaum <benjamingr@gmail.com>2021-02-03 12:04:37 +0200
commit03380bc16aaf731bc599dec4baf4f5668635f587 (patch)
tree3576a90a94ee7f920a83196d030bf0bf2ef0386b /test/parallel/test-readable-from.js
parent861a396a4a6f745d206e5025cfdc2cdaba2e1aa2 (diff)
downloadnode-new-03380bc16aaf731bc599dec4baf4f5668635f587.tar.gz
stream: improve Readable.from error handling
PR-URL: https://github.com/nodejs/node/pull/37158 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-readable-from.js')
-rw-r--r--test/parallel/test-readable-from.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/parallel/test-readable-from.js b/test/parallel/test-readable-from.js
index a4e0f1b566..aca8f5548a 100644
--- a/test/parallel/test-readable-from.js
+++ b/test/parallel/test-readable-from.js
@@ -4,6 +4,7 @@ const { mustCall } = require('../common');
const { once } = require('events');
const { Readable } = require('stream');
const { strictEqual, throws } = require('assert');
+const common = require('../common');
{
throws(() => {
@@ -187,6 +188,25 @@ async function endWithError() {
}
}
+async function destroyingStreamWithErrorThrowsInGenerator() {
+ const validateError = common.mustCall((e) => {
+ strictEqual(e, 'Boum');
+ });
+ async function* generate() {
+ try {
+ yield 1;
+ yield 2;
+ yield 3;
+ throw new Error();
+ } catch (e) {
+ validateError(e);
+ }
+ }
+ const stream = Readable.from(generate());
+ stream.read();
+ stream.once('error', common.mustCall());
+ stream.destroy('Boum');
+}
Promise.all([
toReadableBasicSupport(),
@@ -198,5 +218,6 @@ Promise.all([
toReadableOnDataNonObject(),
destroysTheStreamWhenThrowing(),
asTransformStream(),
- endWithError()
+ endWithError(),
+ destroyingStreamWithErrorThrowsInGenerator(),
]).then(mustCall());