When using an oversized buffer, the flush callback is only sometimes called.
'use strict';constzlib=require('zlib');constbuf=newBuffer(100000);constdef=zlib.createDeflate({highWaterMark:5,level: 2});def.on('drain',()=>console.log('drained'));def.write(buf,()=>{console.log('after write');def.flush(zlib.Z_FULL_FLUSH,function(err){console.log('flushed');});def.end();});bash-3.2$ ./node ~/test.js
drained
after write
bash-3.2$ ./node ~/test.js
drained
after write
flushed
bash-3.2$
Relevant IRC Chat
15:46 jasnell: not yet... the inconsistency seems to have something to do with the size of the buffer
15:46 jasnell: if I drop down to Buffer(10000), it works fine
15:46 chrisdickinson: that's < zlib window size
15:47 chrisdickinson: it might be in limbo waiting for a corresponding read
15:47 thealphanerd: adding a read does give a consisent flush
15:48 jasnell: ok, makes for a rather tricky inconsistency
15:48 jasnell: sometimes it works, sometimes it doesn't, with no indication as to why
15:50 thealphanerd: jasnell: I think you can check to see if write returns false?
15:51 chrisdickinson: ah
15:51 chrisdickinson: might see how many times the handle is written to per-buffer
15:51 chrisdickinson: https://github.com/nodejs/node/blob/v4.2.1/lib/zlib.js#L588-L593
Will be getting back to this to investigate. @chrisdickinson@thealphanerd
Related to: #3534
When using an oversized buffer, the flush callback is only sometimes called.
Relevant IRC Chat
Will be getting back to this to investigate. @chrisdickinson@thealphanerd
Related to: #3534