node/test/parallel/test-stream-pipeline-uncaught.js
Robert Nagy db28739aed stream: fix broken pipeline error propagation
If the destination was an async function any
error thrown from that function would be swallowed.

PR-URL: https://github.com/nodejs/node/pull/31835
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2020-02-24 12:20:49 +01:00

26 lines
568 B
JavaScript

'use strict';
const common = require('../common');
const {
pipeline,
PassThrough
} = require('stream');
const assert = require('assert');
process.on('uncaughtException', common.mustCall((err) => {
assert.strictEqual(err.message, 'error');
}));
// Ensure that pipeline that ends with Promise
// still propagates error to uncaughtException.
const s = new PassThrough();
s.end('data');
pipeline(s, async function(source) {
for await (const chunk of source) {
chunk;
}
}, common.mustCall((err) => {
assert.ifError(err);
throw new Error('error');
}));