-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zlib: inconsistent call to flush callback on oversized buffers #3782
Comments
Further discussion in IRC points to: when passing a large amount of data into zlib, the readable state's highwatermark may max out. When this happens, the writable buffer cannot fully flush until the readable state is cleared. |
The fix for this is to improve the documentation and provide an example of dealing with large amounts of compressed data. |
@chrisdickinson / @jasnell please correct me if I am wrong, but does this not apply as a general case in Duplex / transform streams? If so should this be documented in Zlib or in the general stream documentation? |
@thealphanerd I'd lean towards noting this in the zlib docs. |
@nodejs/documentation |
@lordKnighton Not really… the current docs only refer to how This is actually not very zlib-specific – the same mechanism is at work in code like this: const stream = require('stream');
const s = new stream.PassThrough({
highWaterMark: 5
});
s.write('Hello, World!', () => console.log('Wrote first chunk'));
s.write('', () => console.log('Wrote empty chunk')); The second callback will not be invoked because the (Readable’s) The only thing that’s a little specific to zlib here is the choice of the method name |
What @chrisdickinson was referring to was that |
Nice response, 👍 for the explanation. |
Describe that `zlib.flush()` may wait for pending writes and until output is being read from the stream. Fixes: nodejs#3782 PR-URL: nodejs#6172 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com>
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
The text was updated successfully, but these errors were encountered: