Skip to content

Readable stream API #29396

@ronag

Description

@ronag

I thought I had a pretty good understanding of streams until I started digging into Readable.

As far as I understand there are 3+ ways to work with streams:

  1. readable.pipe
  2. readable.on('readable')/readable.read()
  3. readable.pause()/readable.resume()
  4. (stream.pipeline)

Since I have trouble following the implementations of 1 and 2 (even before digging). I have always only trusted and used 3. Furthermore I've enforced the rest of our team to use this together with some rules and helpers.

Though after reading the code and docs I have a feeling 3. is considered legacy?

While the docs are very good at describing how the different modes work. I have not been able to figure out from the docs what method is recommended/appropriate when and why.

Why do we have 3 modes (other than backwards compat)? Could we explicitly (doc) deprecate or possibly recommend one of them or alternatively why and when to use each one?

I'd be more than happy to make suggestions to improve the docs once I understand this myself.

Furthermore, I have a feeling that 98% of our users should not bother with any of this and just simply use stream.pipeline. I would suggest we earlier and more explicitly try to recommend and forward readers of the streams docs to pipeline and leave the rest explicitly for "advanced" users. Especially as pipeline takes very good care of and normalizes a lot of the complexities and inconsistencies that exist (some of which are either not documented at all or ambiguous). Maybe more explicitly splitting the docs into basic (98%) and advanced (2%) would be helpful?

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