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
5 changes: 4 additions & 1 deletion lib/internal/streams/pipeline.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,10 @@ function once(callback) {
};
}

function noop() {}
function noop(err) {
// Rethrow the error if it exists to avoid swallowing it
if (err) throw err;
}

function isRequest(stream) {
return stream.setHeader && typeof stream.abort === 'function';
Expand Down
38 changes: 35 additions & 3 deletions test/parallel/test-stream-pipeline.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,7 +142,7 @@ common.crashOnUnhandledRejection();
}
});

pipeline(rs, res);
pipeline(rs, res, () => {});
});

server.listen(0, () => {
Expand DownExpand Up@@ -177,7 +177,7 @@ common.crashOnUnhandledRejection();
})
});

pipeline(rs, res);
pipeline(rs, res, () => {});
});

server.listen(0, () => {
Expand DownExpand Up@@ -206,7 +206,7 @@ common.crashOnUnhandledRejection();
})
});

pipeline(rs, res);
pipeline(rs, res, () => {});
});

let cnt = 10;
Expand DownExpand Up@@ -481,3 +481,35 @@ common.crashOnUnhandledRejection();

run();
}

{
const read = new Readable({
read() {}
});

const transform = new Transform({
transform(data, enc, cb) {
cb(new Error('kaboom'));
}
});

const write = new Writable({
write(data, enc, cb) {
cb();
}
});

read.on('close', common.mustCall());
transform.on('close', common.mustCall());
write.on('close', common.mustCall());

process.on('uncaughtException', common.mustCall((err) => {
assert.deepStrictEqual(err, new Error('kaboom'));
}));

const dst = pipeline(read, transform, write);

assert.strictEqual(dst, write);

read.push('hello');
}