From 5955dfb6f2366139d541016bfbd0ac297457dffe Mon Sep 17 00:00:00 2001 From: Sankha Narayan Guria Date: Sat, 14 May 2016 23:27:06 +0530 Subject: [PATCH] stream: Correct bufferedRequestCount in writes --- lib/_stream_writable.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 76c4972d405c81..5944d636844d33 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -403,6 +403,7 @@ function clearBuffer(stream, state) { } else { state.corkedRequestsFree = new CorkedRequest(state); } + state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one while (entry) { @@ -413,6 +414,7 @@ function clearBuffer(stream, state) { doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then // it means that we need to wait until it does. // also, that means that the chunk and cb are currently @@ -426,7 +428,6 @@ function clearBuffer(stream, state) { state.lastBufferedRequest = null; } - state.bufferedRequestCount = 0; state.bufferedRequest = entry; state.bufferProcessing = false; }