Skip to content

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

Closed
@dy-dx

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.

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