Skip to content

stream.compose does not preserve 'readableObjectMode' from final stream to returned stream #46829

Closed
@loganfsmyth

Description

@loganfsmyth

Version

v19.7.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

const stream = require("stream");

const s = stream.compose(
  stream.Readable.from("0 1 2 3 4"),
  new stream.Transform({
    readableObjectMode: true,
    transform: function (val, enc, callback) {
      for (const num of val.toString().split(" ")) {
        this.push(`${num}`);
      }
      callback();
    },
  })
);

s.on("readable", () => {
  let data;
  while ((data = s.read()) !== null) {
    console.log("read:", `${data}`);
  }
});
s.on("end", () => {
  console.log("done");
});

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

No response

What is the expected behavior?

Should output

read: 0
read: 1
read: 2
read: 3
read: 4
done 

What do you see instead?

read: 01234
read: null
done

Additional information

No response

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