Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
ronag committed Jul 12, 2021
commit 0cf9ee54c2e5d4e3257b6f17ed8a835bf5eceb5a
8 changes: 2 additions & 6 deletions lib/internal/streams/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ module.exports = function compose(...streams) {
cb(err);
} else if (err) {
d.destroy(err);
} else if (!readable && !writable) {
d.destroy();
}
}

Expand Down Expand Up @@ -182,12 +184,6 @@ module.exports = function compose(...streams) {
};
}

if (!readable && !writable) {
tail.on('finish', function() {
d.destroy();
});
}

d._destroy = function(err, callback) {
if (!err && onclose !== null) {
err = new AbortError();
Expand Down
10 changes: 9 additions & 1 deletion lib/internal/streams/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ function isWritableNodeStream(obj) {
}

function isNodeStream(obj) {
return isReadableNodeStream(obj) || isWritableNodeStream(obj);
return (
obj &&
(
obj._readableState ||
obj._writableState ||
(typeof obj.write === 'function' && typeof obj.on === 'function') ||
(typeof obj.pipe === 'function' && typeof obj.on === 'function')
)
);
}

function isIterable(obj, isAsync) {
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-stream-compose.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Flags: --expose-internals

'use strict';

const common = require('../common');
Expand All @@ -6,9 +8,9 @@ const {
Transform,
Writable,
finished,
compose,
PassThrough
} = require('stream');
const compose = require('internal/streams/compose');
const assert = require('assert');

{
Expand Down