Skip to content

stream.isReadable and stream.isWritable return null instead of false #59006

Description

@RReverser

Version

v24.2.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

Try these functions in REPL:

stream.isReadable(new stream.Readable())
true
stream.isReadable(new stream.Writable())
null
stream.isWritable(new stream.Writable())
true
stream.isWritable(new stream.Readable())
null

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

It should always return a boolean as per docs.

What do you see instead?

true and null

Additional information

No response

Activity

  1. michaelficarra commented on Jul 9, 2025

    @michaelficarra
    Contributor

    The docs say that the only valid parameters are <Readable> | <Duplex> | <ReadableStream>. So I think it's reasonable that it returns null or throws when passed something else. Are you just looking for the docs to be updated?

  2. jasnell commented on Jul 9, 2025

    @jasnell
    Member

    I'd suggest that the API as currently defined is buggy / incomplete. It really ought to return boolean in every case.

  3. michaelficarra commented on Jul 9, 2025

    @michaelficarra
    Contributor

    What should the parameter type be?

  4. RReverser commented on Jul 9, 2025

    @RReverser
    MemberAuthor

    I'd say same list as stream.isErrored:

    stream.isErrored(stream)
    
    stream <Readable> | <Writable> | <Duplex> | <WritableStream> | <ReadableStream>
    Returns: <boolean>
    

    Although I'd also replace <Readable> | <Writable> | <Duplex> with just <Stream> (which should be no-op replacement, just a bit clearer).

  5. Haroenv commented on Jul 10, 2025

    @Haroenv
  6. RReverser commented on Jul 10, 2025

    @RReverser
    MemberAuthor

    but this should be the same for the other ones in this file?

    Those seem to be just some internal helpers? I don't see them on https://nodejs.org/api/stream.html

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

    confirmed-bugIssues and PRs for confirmed bugs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions