From ce30b2719ea5cdb5b99c899045807510598ff30a Mon Sep 17 00:00:00 2001 From: Vishal Bisht Date: Tue, 10 Apr 2018 12:14:29 +0530 Subject: [PATCH 1/2] stream: highWaterMark checks fix --- lib/_stream_readable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5b044e79c1b18d..5147503a53615a 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -311,8 +311,7 @@ function chunkInvalid(state, chunk) { // 'readable' event will be triggered. function needMoreData(state) { return !state.ended && - (state.length < state.highWaterMark || - state.length === 0); + (state.length < state.highWaterMark); } Readable.prototype.isPaused = function() { @@ -434,7 +433,7 @@ Readable.prototype.read = function(n) { debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { + if (state.length - n < state.highWaterMark) { doRead = true; debug('length less than watermark', doRead); } From 1d461cb4372b9fff23a9b304e113b06d2fa82ff1 Mon Sep 17 00:00:00 2001 From: Vishal Bisht Date: Thu, 12 Apr 2018 00:30:11 +0530 Subject: [PATCH 2/2] stream: removed parentheses and changed comparison operator to <= in highWaterMark (needMoreData function) --- lib/_stream_readable.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5147503a53615a..9a673f6425fd2c 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -310,8 +310,7 @@ function chunkInvalid(state, chunk) { // needReadable was set, then we ought to push more, so that another // 'readable' event will be triggered. function needMoreData(state) { - return !state.ended && - (state.length < state.highWaterMark); + return !state.ended && state.length <= state.highWaterMark; } Readable.prototype.isPaused = function() {