diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 020d7abcc0..90aa285865 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -71,13 +71,13 @@ Writable.prototype.write = function(chunk, encoding) { if (typeof chunk === 'string') chunk = new Buffer(chunk, encoding); - var ret = state.length >= state.highWaterMark; - if (ret === false) - state.needDrain = true; - var l = chunk.length; state.length += l; + var ret = state.length < state.highWaterMark; + if (ret === false) + state.needDrain = true; + if (state.writing) { state.buffer.push(chunk); return ret;