Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/internal/streams/from.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function from(Readable, iterable, opts) {

const readable = new Readable({
objectMode: true,
highWaterMark: 1,
// TODO(ronag): What options should be allowed?
...opts
});

Expand Down
26 changes: 25 additions & 1 deletion test/parallel/test-readable-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ async function asTransformStream() {
}
}

async function endWithError() {
async function* generate() {
yield 1;
yield 2;
yield Promise.reject('Boum');
}

const stream = Readable.from(generate());

const expected = [1, 2];

try {
for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
}
throw new Error();
} catch (err) {
strictEqual(expected.length, 0);
strictEqual(err, 'Boum');
}
}


Promise.all([
toReadableBasicSupport(),
toReadableSyncIterator(),
Expand All @@ -168,5 +191,6 @@ Promise.all([
toReadableOnData(),
toReadableOnDataNonObject(),
destroysTheStreamWhenThrowing(),
asTransformStream()
asTransformStream(),
endWithError()
]).then(mustCall());