-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
a1b095d
commit 77e0318
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { Readable } = require('stream'); | ||
|
||
// Make sure that readable completes | ||
// even when reading larger buffer. | ||
const bufferSize = 10 * 1024 * 1024; | ||
let n = 0; | ||
const r = new Readable({ | ||
read() { | ||
// Try to fill readable buffer piece by piece. | ||
r.push(Buffer.alloc(bufferSize / 10)); | ||
|
||
if (n++ > 10) { | ||
r.push(null); | ||
} | ||
} | ||
}); | ||
|
||
r.on('readable', () => { | ||
while (true) { | ||
const ret = r.read(bufferSize); | ||
if (ret === null) | ||
break; | ||
} | ||
}); | ||
r.on('end', common.mustCall()); |