Skip to content

Commit 27999bf

Browse files
committed
fixup: don't read more if failed
1 parent aabfd75 commit 27999bf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/internal/streams/operators.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports.map = function map(stream, fn, options) {
7070
try {
7171
return [null, await val];
7272
} catch (err) {
73-
return [err, null];
73+
stream.destroy(err);
7474
}
7575
}
7676

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

8484
function pump () {
85-
while (queue.length < concurrency) {
86-
let val = stream.read();
87-
if (val === null) {
88-
return;
89-
}
90-
try {
85+
try {
86+
while (queue.length < concurrency) {
87+
let val = stream.read();
88+
if (val === null) {
89+
return;
90+
}
9191
val = fn(val, { signal });
9292
if (val && typeof val.then === 'function') {
9393
enqueue(wrap(val));
9494
} else {
9595
enqueue([null, val]);
9696
}
97-
} catch (err) {
98-
enqueue([err, null]);
9997
}
98+
} catch (err) {
99+
stream.destroy(err);
100100
}
101101
}
102102

0 commit comments

Comments
 (0)