Skip to content

stream: .read() when piping can stop the flow of data #18512

@mafintosh

Description

@mafintosh
  • Version: >= 4
  • Platform: Linux
  • Subsystem: stream

Run the following test case, that produces an infinite stream that is piped to a simple writable stream. If you do a read in between when the destination's buffer is full, the pipe breaks.

var stream = require('stream')

var rs = stream.Readable({
  objectMode: true,
  read: () => rs.push({})
})

setImmediate(function () {
  rs.read()
})

var ws = stream.Writable({
  objectMode: true,
  write: (data, enc, cb) => {
    console.log(data)
    setTimeout(cb, 10)
  }
})

rs.pipe(ws)

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions