sindresorhus/merge-streams

`stream.unpipe(mergedStream)` prevents the merged stream from completing

Closed this issue · 0 comments

When one of the input streams is unpiped from the merged stream, the merged stream never completes.

const inputStream = Readable.from(['.']);
const stream = mergeStreams([inputStream]);
inputStream.unpipe(stream);
await stream.toArray() // This never resolves

We should listen to the unpipe event, and mark unpiped streams as "complete".

See also https://github.com/grncdr/merge-stream/blob/a217797ff4a52581423ca1fc6eef409c4c992447/index.js#L14