-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 deflate/inflate failure #30976
Comments
Here is a test case: const zlib = require('zlib');
const data = zlib.deflateRawSync('Welcome');
const chunks = [];
const inflate = zlib.createInflateRaw();
inflate.on('data', function(chunk) {
chunks.push(chunk);
});
inflate.write(data);
inflate.write(Buffer.from([0x00, 0x00, 0xff, 0xff]));
inflate.flush(function() {
const buf = Buffer.concat(chunks);
console.log(buf.toString());
}); The problem is that Decompression follows the RFC 7692 specifications. It is possible to use the inflate.on('end', function() {
const buf = Buffer.concat(chunks);
console.log(buf.toString());
}); is added to the above example it will work as expected but is it intended? |
cc: @addaleax |
This isn’t specific to flushes – in const zlib = require('zlib');
const data = zlib.deflateRawSync('Welcome');
const inflate = zlib.createInflateRaw();
inflate.resume();
inflate.write(data, () => console.log('write 1 done'));
inflate.write(Buffer.from([0x00]), () => console.log('write 2 done'));
inflate.write(Buffer.from([0x00]), () => console.log('write 3 done')); only the first two writes finish. I’ll try to figure out why that is. |
I did not investigate but I think it's because the inflate stream is no longer readable after a block with the |
@lpinca Yeah, but other |
Call the callback for writes that occur after the stream is closed. This also requires changes to the code to not call `.destroy()` on the stream in `.on('end')`, and to ignore chunks written afterwards. Previously, these writes would just queue up silently, as their `_write()` callback would never have been called. Fixes: nodejs#30976
Call the callback for writes that occur after the stream is closed. This also requires changes to the code to not call `.destroy()` on the stream in `.on('end')`, and to ignore chunks written afterwards. Previously, these writes would just queue up silently, as their `_write()` callback would never have been called. Fixes: #30976 PR-URL: #31082 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Call the callback for writes that occur after the stream is closed. This also requires changes to the code to not call `.destroy()` on the stream in `.on('end')`, and to ignore chunks written afterwards. Previously, these writes would just queue up silently, as their `_write()` callback would never have been called. Fixes: #30976 PR-URL: #31082 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Call the callback for writes that occur after the stream is closed. This also requires changes to the code to not call `.destroy()` on the stream in `.on('end')`, and to ignore chunks written afterwards. Previously, these writes would just queue up silently, as their `_write()` callback would never have been called. Fixes: #30976 PR-URL: #31082 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Hi,
I reported an issue against ws (websockets/ws#1669) which actually can be traced back to NodeJS (851a691678 - #26363), introduced from 11.10.1 to 11.11.0.
Essentially there is some deflate'd data that cannot be uncompressed successfully. I hope it's okay to point to related issue for code samples and further discussion. If not please tell - I'll extend this report.
The text was updated successfully, but these errors were encountered: