Skip to content

Commit

Permalink
stream: catch and forward error from dest.write
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecastelli committed Oct 18, 2024
1 parent e2242b4 commit c01a0b9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,10 +1004,15 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
src.on('data', ondata);
function ondata(chunk) {
debug('ondata');
const ret = dest.write(chunk);
debug('dest.write', ret);
if (ret === false) {
pause();
try {
const ret = dest.write(chunk);
debug('dest.write', ret);

if (ret === false) {
pause();
}
} catch (error) {
dest.destroy(error);
}
}

Expand Down

0 comments on commit c01a0b9

Please sign in to comment.