stream: writes may return false but forget to emit drain
authorayanamist <contact@ayanamist.com>
Fri, 3 Jan 2014 11:37:16 +0000 (19:37 +0800)
committerFedor Indutny <fedor.indutny@gmail.com>
Sun, 5 Jan 2014 15:44:45 +0000 (19:44 +0400)
commitb922b5e90d2c14dd332b95827c2533e083df7e55
treeb3bb6326380159798bf9af5a2f4cc790ad91b8e7
parentaa56d9d35405a56b8478c0a83106ffa4ada903db
stream: writes may return false but forget to emit drain

If a write is above the highWaterMark, _write still manages to
fully send it synchronously, _writableState.length will be adjusted down
to 0 synchronously with the write returning false, but 'drain' will
not be emitted until process.nextTick.

If another small write which is below highWaterMark is issued before
process.nextTick happens, _writableState.needDrain will be reset to false,
and the drain event will never be fired.

So we should check needDrain before setting it up, which prevents it
from inproperly resetting to false.
lib/_stream_writable.js
test/simple/test-stream-big-packet.js [new file with mode: 0644]