Skip to content

Flow problem with node >= 10.10 #48

Description

@arantes555

Hi,

I'm running into an issue with all node versions >= 10.10.

The problem is that, sometimes (I cannot pinpoint exactly under which conditions), putting streams into multipipe seems to stop the flow, so streams are piped but no data is actually flowing.

As a test, you can run the following code:

const multipipe = require('multipipe')

const { PassThrough } = require('stream')

const stringToStream = (string) => {
  const myStream = new PassThrough()
  myStream.end(Buffer.from(string, 'binary'))
  return myStream
}

const str = 'a'.repeat(1e6)

const returnStream = new PassThrough()

let tmp = ''
returnStream
  .on('data', (chunk) => {
    tmp += chunk
  })
  .on('end', () => {
    console.log(tmp.length)
  })

const input = stringToStream(str)
const outputStream = multipipe(new PassThrough(), returnStream)
multipipe(input, outputStream)
// outputStream.resume()

On node < 10.10, you get a log of 1000000, as is expected.

On node >= 10.10, you get nothing, except if you uncomment the last line.

This unexpected behaviour is easy to workaround (just add a .resume()), but quite annoying... It seems linked to nodejs/node#22209 and nodejs/node#18994 .

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions