Repository navigation
Node 16.14.2 highWaterMark:0 doesn't handle backpressure #42457
Description
Activity
- changed the title
[-]Node 16.14.2 highWaterMark:0 does handle backpressure[/-][+]Node 16.14.2 highWaterMark:0 doesn't handle backpressure[/+]on Mar 24, 2022 - addedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Mar 24, 2022 @nodejs/streams
It seems #40947 should not have been backported at least.
@kanongil @paulrutter what behavior were you expecting for
highWaterMark: 0? Was this documented anywhere at all?My thought with using highwatermark 0 was to not buffer any chunks, instead just wait until the current chunk is done and then proceed to the next chunk.
I don't think the docs describe using 0 specifically, but it worked for my usecase so i didn’t give it more thought until it broke in node16.Essentially you assumed that it would be the same behavior of
highWaterMark: 1?In my mind a value of 0 would be "false", so no buffering at all. The current behavior matches that description.
Yes, true. In hindsight, using 1 would have made more sense. Still i think it's not great that the change is not backwards compatible anymore.
In that I agree.
@nodejs/tsc @nodejs/releasers, what should we do?
I use
highWaterMark: 0to enable an object mode transform stream to be pull-based.This means a call to
stream.read()will initially returnnull, and once'readable'triggers, I canstream.read()a single element out of it. Then I have the option to do anotherstream.read()to trigger a new pull, or just wait until it suits me.When applied to a
Transformstream that is piped into, it means that it internally only stores 1 incoming object (in the write end), before applying backpressure.writableHighWaterMark: 0, readableHighWaterMark: 1doesn't work, since it will cause 2 objects to be internally buffered. 1 on the write side, and 1 in the read side.@ronag you should chime in on this one, because it looks like we might want to revert to the original behavior.
I'll try to have a look next week.
Reacted by Richard LauI'm not sure hwm of 0 makes any sense. Maybe the simple solution is to simply automatically change 0 to 1?
4 remaining items
@mcollina Yes, looking into making a PR right now.
Hmm, it appears that my issue it not the same as this (at least the reproduction code). The reproduction code relies on calling
write()into a stream that returnsfalse. This makes the case fundamentally incompatible with the new transform-on-write model which was already present in v16.0.As such my fix doesn't handle this exact issue, though it might fix the actual issue this is based on.
PR up in #43648. As per my previous comment, it doesn't fix the exact reproduction code from this issue, but it fixes the regression in my transform stream.
- added a commit that references this issue
on Jul 1, 2022 - added a commit that references this issue
on Jul 24, 2022 - added a commit that references this issue
on Jul 26, 2022 - added a commit that references this issue
on Oct 10, 2022 github-actions commented
on Jun 25, 2026 on Jun 25, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jun 25, 2026
Version
16.14.2
Platform
x64
Subsystem
No response
What steps will reproduce the bug?
I wouldn't expect the
transformmethod to be called, while the highWaterMark is already reached.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Node 14 and older, backpressure is handled properly (even with highWaterMark: 0):
Expected output:
What do you see instead?
Additional information
When using
highWaterMark: 1in Node 16.x, backpressure works as expected again.Did anything change around using
highWaterMark:0in Node16? It doesn't seem backwards compatible.