Skip to content

piping to a stream with highWaterMark: 0 and objectMode: false is broken since node v20.10.0 #51930

Description

@dy-dx

Version

v21.6.2

Platform

Darwin x86_64

Subsystem

stream

What steps will reproduce the bug?

const { Readable, Writable } = require('stream');

const r = new Readable({
  read() {}
});

const w = new Writable({
  highWaterMark: 0,
  write(chunk, encoding, callback) {
    console.log(chunk.toString());
    callback();
  },
});

r.pipe(w);

r.push('hello');
r.push('world');
r.push(null);

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

Always

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

In node v20.9.0 and earlier:

hello
world

What do you see instead?

In node v20.10.0 and later, only the first chunk ever arrives at the destination:

hello

Additional information

The issue is present on node v20.10.0, but is not present on v20.9.0. The issue is also present on v21.0.0.

A workaround is to use highWaterMark: 1.

Activity

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

    streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions