Skip to content

stream: standardize async initialization #29314

Closed
@ronag

Description

@ronag

Some streams (e.g.fs and net) need to first asynchronously create resources before they can perform any work. Currently this is implemented in the different stream implementations which both makes things more difficult and error prone (e.g. 'open' and 'ready' are emitted after 'close'). I suggest we provide a standardized way of achieving this.

This would allow further simplification and improved consistency for various stream implementations such as fs and net stream.

I propose the following API for this:

  • a stream._construct(cb) endpoint (similar to _destroy(cb)).
  • a stream.ready property indicating whether the stream is ready (currently this is called pending in some implementations). Including readableReady and writableReady accessors.
  • a 'ready' event (currently this is called 'open' in some implementations).

See, nxtedition#2 for proof of concept.

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