Skip to content

Commit

Permalink
fixup: don't read more if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 17, 2021
1 parent aabfd75 commit 27999bf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/internal/streams/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports.map = function map(stream, fn, options) {
try {
return [null, await val];
} catch (err) {
return [err, null];
stream.destroy(err);
}
}

Expand All @@ -82,21 +82,21 @@ module.exports.map = function map(stream, fn, options) {
}

function pump () {
while (queue.length < concurrency) {
let val = stream.read();
if (val === null) {
return;
}
try {
try {
while (queue.length < concurrency) {
let val = stream.read();
if (val === null) {
return;
}
val = fn(val, { signal });
if (val && typeof val.then === 'function') {
enqueue(wrap(val));
} else {
enqueue([null, val]);
}
} catch (err) {
enqueue([err, null]);
}
} catch (err) {
stream.destroy(err);
}
}

Expand Down

0 comments on commit 27999bf

Please sign in to comment.