Skip to content

eos and stream type detection #29395

Closed
Closed
@ronag

Description

@ronag

Looking at https://github.com/nodejs/node/blob/master/lib/internal/streams/end-of-stream.js#L31

It looks like "eos" uses the writable and readable properties to detect whether a stream is Readablelike or Writablelike. However, according my current incomplete understanding of these properties (#29377), they cannot/should not be used for this purpose, i.e. a Readable stream could in theory have a readable = false which later becomes a readable = true.

Should we maybe change these lines to something like e.g:

const isReadable = (
  typeof stream.readable === 'boolean' || 
  stream._readableState || 
  typeof stream.readableEnded === 'boolean'
);
let readable = opts.readable || (opts.readable !== false && isReadable);

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