Skip to content
Open
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
7 changes: 6 additions & 1 deletion lib/internal/streams/duplexify.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ module.exports = function duplexify(body, name) {
// The async function returned without (fully) consuming the input.
// Destroy the duplex so that pipeline propagates destruction
// upstream. See https://github.com/nodejs/node/issues/55077.
// Destroy it directly rather than through destroyer(), which
// synthesizes an AbortError for any stream that is not finished.
// The function resolved successfully, so there is no error to
// report, and a duplex outside of a pipeline has nothing listening
// for one.
if (!finalized) {
destroyer(d);
d.destroy();
}
},
(err) => {
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-stream-duplex-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,15 @@ function makeATestWritableStream(writeFunc) {
}),
);
}

// Regression for the fix to https://github.com/nodejs/node/issues/55077:
// an AsyncFunction that returns without consuming its input is destroyed, but
// that destruction must not be reported as an error. Outside of a pipeline
// there is nothing listening for one, so an error here is unhandled and takes
// the process down.
{
const duplex = Duplex.from(async function() {
// Intentionally do not consume the async iterable input.
});
duplex.on('error', common.mustNotCall());
}
Loading