stream: increase MAX_HWM · nodejs/node@88adad2 · GitHub
Skip to content

Commit 88adad2

Browse files
ronagMylesBorins
authored andcommitted
stream: increase MAX_HWM
MAX_HWM was added in 9208c89 where the highwatermark was changed to always increase in steps of highest power of 2 to prevent increasing hwm excessivly in tiny amounts. Why a limit was added on the highwatermark is unclear but breaks existing usage where a larger read size is used. The invariant for read(n) is that a buffer of size n is always returned. Considering a maximum ceiling on the buffer size breaks this invariant. This PR significantly increases the limit to make it less likely to break the previous invariant and also documents the limit. Fixes: #29933 PR-URL: #29938 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 3710068 commit 88adad2

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

doc/api/stream.md

Lines changed: 2 additions & 0 deletions

lib/_stream_readable.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,11 @@ Readable.prototype.setEncoding = function(enc) {
358358
return this;
359359
};
360360

361-
// Don't raise the hwm > 8MB
362-
const MAX_HWM = 0x800000;
361+
// Don't raise the hwm > 1GB
362+
const MAX_HWM = 0x40000000;
363363
function computeNewHighWaterMark(n) {
364364
if (n >= MAX_HWM) {
365+
// TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
365366
n = MAX_HWM;
366367
} else {
367368
// Get the next highest power of 2 to prevent increasing hwm excessively in
Lines changed: 27 additions & 0 deletions

0 commit comments

Comments
 (0)