-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.zlibIssues and PRs related to the zlib subsystem.Issues and PRs related to the zlib subsystem.
Description
When using an oversized buffer, the flush callback is only sometimes called.
'use strict';
const zlib = require('zlib');
const buf = new Buffer(100000);
const def = 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
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.zlibIssues and PRs related to the zlib subsystem.Issues and PRs related to the zlib subsystem.