Repository navigation
zlib: preserve brotli params and dictionary on reset - #66157
Conversation
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: nodejs#66156 Signed-off-by: Xia Chao <[email protected]>
The markdown linter rejects pr-url: REPLACEME. Signed-off-by: Xia Chao <[email protected]>
|
@jasnell |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66157 +/- ##
==========================================
- Coverage 90.28% 90.27% -0.02%
==========================================
Files 790 790
Lines 271974 272007 +33
Branches 51919 51936 +17
==========================================
- Hits 245560 245550 -10
- Misses 16907 16952 +45
+ Partials 9507 9505 -2
🚀 New features to boost your workflow:
|
|
@MikeMcC399 |
There have also been reports in Slack https://openjs-foundation.slack.com/archives/C03BJP63CH0 about this issue. Hopefully the build team will be taking a look. Unfortunately I don't have any influence on this, but if it is affecting multiple PRs, then I would assume it is going to get fixed soon. |
|
Landed in 1e0167d |
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: #66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: #66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: nodejs#66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: nodejs#66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: #66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: #66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: #66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: #66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
…i stream It started the new stream with the defaults, as Node did until nodejs/node#66157. The dictionaries move from the old encoder or decoder to the new one, so they are neither copied nor indexed again. Also a test through node:zlib for a stream offset with a dictionary.
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: #66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: #66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
ResetStream currently calls Init() with no arguments, which drops the stored dictionary and never replays SetParams. Remember each successful parameter and replay both the dictionary and the params when the stream is reset. Fixes: #66156 Signed-off-by: Xia Chao <[email protected]> PR-URL: #66157 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
reset()on a Brotli compressor or decompressor threw away the quality/paramsand dictionary you set at construction. Nothing failed — the next compress just
ran with the defaults, and a dictionary decoder then rejected the frame.
Fixes: #66156
The problem
BrotliEncoderContext::ResetStreamandBrotliDecoderContext::ResetStreamboth did
return Init();with no arguments.Init()clearsdictionary_andbuilds a brand-new Brotli instance. It never replays
SetParams.So this:
compressed as if you had written
createBrotliCompress()with no options.A decoder created with that same dictionary, then reset, failed with
ERR__ERROR_FORMAT_DICTIONARY.reset()is supposed to start a new session on the same stream, not throwthe constructor options away. That is already documented for Zstd, and
test/parallel/test-zlib-zstd-reset.jsalready asserts it.This is not #66087 / #66088. Those are about
flush()thenreset()leavinga broken frame. Here there is no write at all — only the configuration is
dropped.
The fix
Remember each successful
SetParamscall. Onreset(), copy the storeddictionary and params,
Init()with that dictionary, then replay the paramson the new instance. Encoder and decoder both do this.
After the change, the snippet above keeps quality 0 and the dictionary.
createBrotliDecompress({ dictionary }).reset()can still decode adictionary-compressed frame.
Tests
test/parallel/test-zlib-brotli-reset.jsmirrors the zstd reset tests:compress options survive
reset(), and a decoder keeps its dictionary.