René's URL Explorer Experiment


Title: zlib: Brotli reset() drops quality and dictionary · Issue #66156 · nodejs/node · GitHub

Open Graph Title: zlib: Brotli reset() drops quality and dictionary · Issue #66156 · nodejs/node

X Title: zlib: Brotli reset() drops quality and dictionary · Issue #66156 · nodejs/node

Description: Version v27.0.0-pre (built from main at a2a051cd42; src/node_zlib.cc is unchanged on current main) Platform Linux x86_64 (Ubuntu 22.04, built with clang 20) Subsystem zlib What steps will reproduce the bug? Create a Brotli compressor wit...

Open Graph Description: Version v27.0.0-pre (built from main at a2a051cd42; src/node_zlib.cc is unchanged on current main) Platform Linux x86_64 (Ubuntu 22.04, built with clang 20) Subsystem zlib What steps will reproduce...

X Description: Version v27.0.0-pre (built from main at a2a051cd42; src/node_zlib.cc is unchanged on current main) Platform Linux x86_64 (Ubuntu 22.04, built with clang 20) Subsystem zlib What steps will reproduce...

Opengraph URL: https://github.com/nodejs/node/issues/66156

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"zlib: Brotli reset() drops quality and dictionary","articleBody":"### Version\n\nv27.0.0-pre (built from `main` at `a2a051cd42`; `src/node_zlib.cc` is unchanged on current `main`)\n\n### Platform\n\n```text\nLinux x86_64 (Ubuntu 22.04, built with clang 20)\n```\n\n### Subsystem\n\nzlib\n\n### What steps will reproduce the bug?\n\nCreate a Brotli compressor with a custom quality or a dictionary, call `.reset()` **before writing anything**, then compress as usual.\n\nThe quality/dictionary you passed in is gone. Nothing throws.\n\n```js\nimport * as zlib from 'node:zlib';\n\nconst input = Buffer.from('the quick brown fox jumps over the lazy dog '.repeat(100));\nconst dict = Buffer.from('the quick brown fox jumps over the lazy dog '.repeat(40));\n\nfunction compress(options, reset) {\n  return new Promise((resolve, reject) => {\n    const s = zlib.createBrotliCompress(options);\n    const chunks = [];\n    s.on('data', (d) => chunks.push(d));\n    s.on('error', reject);\n    if (reset) s.reset();\n    s.end(input);\n    s.on('end', () => resolve(Buffer.concat(chunks).length));\n  });\n}\n\nconst q0 = { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 0 } };\nconsole.log('quality 0, no reset:', await compress(q0, false));  // 109\nconsole.log('quality 0, then reset:', await compress(q0, true)); // 55  (same as default quality 11)\nconsole.log('with dictionary, no reset:', await compress({ dictionary: dict }, false));  // 18\nconsole.log('with dictionary, then reset:', await compress({ dictionary: dict }, true)); // 55 (same as no dictionary)\n\nconst compressed = zlib.brotliCompressSync(input, { dictionary: dict });\nconst dec = zlib.createBrotliDecompress({ dictionary: dict });\ndec.reset();\ndec.end(compressed);\ndec.on('error', (err) => console.log('decompress after reset:', err.code));\n// ERR__ERROR_FORMAT_DICTIONARY\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways. You do not need to write any data first. Just construct the stream with options and call `reset()`.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`reset()` should start a new Brotli session on the **same** stream, keeping the quality/params and dictionary you already set.\n\nThat is what the same API already documents for Zstd (`zlib.reset()`: \"start a new session while preserving the configured parameters and dictionary\"), and it is what `test/parallel/test-zlib-zstd-reset.js` asserts. Brotli goes through the same JS `reset()` method.\n\nIf the dictionary is dropped, a decoder cannot read a dictionary-compressed frame at all.\n\n### What do you see instead?\n\n- Quality 0 after `reset()` compresses as if you had used the default quality 11 (109 bytes become 55).\n- A dictionary after `reset()` compresses as if you had used no dictionary (18 bytes become 55).\n- `createBrotliDecompress({ dictionary })` then `reset()` fails with `ERR__ERROR_FORMAT_DICTIONARY` on a frame that was compressed with that dictionary.\n\nThe compressor never reports an error. The settings just disappear.\n\n### Additional information\n\nC++: `BrotliEncoderContext::ResetStream` / `BrotliDecoderContext::ResetStream` both do `return Init();` with no arguments. `Init()` immediately does `dictionary_.clear()` and creates a brand-new Brotli instance. It never replays `SetParams`.\n\nThis is not [#66087](https://github.com/nodejs/node/issues/66087) / [#66088](https://github.com/nodejs/node/pull/66088). Those are about `flush()` then `reset()` leaving a broken **frame**. Here there is no write at all — only the **configuration** is thrown away.\n\nLLDB on `src/node_zlib.cc` at `a2a051cd42` (same `ResetStream`/`Init` as current `main`):\n\n1. Stopped in `BrotliEncoderContext::ResetStream` at line 1514. Watch: `this->dictionary_` still has size **1760**. Next statement is `return Init();` with no dictionary argument.\n\n\u003cimg width=\"2620\" height=\"1596\" alt=\"ResetStream at line 1514: dictionary still size 1760, about to call empty Init()\" src=\"https://github.com/user-attachments/assets/2d03d57a-4e30-44e7-a931-33a173947bb0\" />\n\n2. That call lands in `Init` at line 1474, on `dictionary_.clear();`. Watch: the member `this->dictionary_` is **still 1760** (clear has not run yet), but the `dictionary` **parameter** is already size **0**, because `ResetStream` did not pass it in.\n\n\u003cimg width=\"3062\" height=\"1606\" alt=\"Init at line 1474: member dictionary still 1760, parameter dictionary already 0\" src=\"https://github.com/user-attachments/assets/c695f462-f74a-4902-98a9-a966a6521e0f\" />\n\n3. Continue to line 1483, `if (!dictionary.empty())`. Watch: both `this->dictionary_` and the `dictionary` parameter are now size **0**, so the attach-dictionary branch is skipped.\n\n\u003cimg width=\"3008\" height=\"1590\" alt=\"Init at line 1483: both dictionaries size 0, attach branch skipped\" src=\"https://github.com/user-attachments/assets/6c0d650e-05a9-44ed-a235-3366493b71c6\" />","author":{"url":"https://github.com/xia-chao","@type":"Person","name":"xia-chao"},"datePublished":"2026-09-20T12:42:16Z","url":"https://github.com/nodejs/node/issues/66156"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:484910a5-79e9-638a-4ad1-aa75cccda666
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id901C:3C34F7:72AD78:95A968:6AED31B8
html-safe-nonce068d548a19ea5bb52ae6f3f1f54b4957a6b2f657a8e49e63a4d119f68e8d4d8a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDFDOjNDMzRGNzo3MkFENzg6OTVBOTY4OjZBRUQzMUI4IiwidmlzaXRvcl9pZCI6IjQ5NzIxNzQ1MTM4NDQwNzI4ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac8d9f08faebe11cc6b165c62a0c846842f7127a05e6a63a5f25db94210a3cdaa9
hovercard-subject-tagissue:5517869410
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66156/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fae284c8ea9d148490fc17e73acd3af8fec170c7696cccb5ec20f35ad43d7640/nodejs/node/issues/66156
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fae284c8ea9d148490fc17e73acd3af8fec170c7696cccb5ec20f35ad43d7640/nodejs/node/issues/66156
og:image:altVersion v27.0.0-pre (built from main at a2a051cd42; src/node_zlib.cc is unchanged on current main) Platform Linux x86_64 (Ubuntu 22.04, built with clang 20) Subsystem zlib What steps will reproduce...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamexia-chao
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66156#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66156
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66156
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/66156
Reloadhttps://github.com/nodejs/node/issues/66156
Reloadhttps://github.com/nodejs/node/issues/66156
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66156
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66156
#66157https://github.com/nodejs/node/pull/66157
zlib: Brotli reset() drops quality and dictionaryhttps://github.com/nodejs/node/issues/66156#top
#66157https://github.com/nodejs/node/pull/66157
https://github.com/xia-chao
xia-chaohttps://github.com/xia-chao
on Sep 20, 2026https://github.com/nodejs/node/issues/66156#issue-5517869410
#66087https://github.com/nodejs/node/issues/66087
#66088https://github.com/nodejs/node/pull/66088
https://private-user-images.githubusercontent.com/236466140/655363761-2d03d57a-4e30-44e7-a931-33a173947bb0.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTM5Mjk5NTYsIm5iZiI6MTc5MzkyOTY1NiwicGF0aCI6Ii8yMzY0NjYxNDAvNjU1MzYzNzYxLTJkMDNkNTdhLTRlMzAtNDRlNy1hOTMxLTMzYTE3Mzk0N2JiMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYxMTA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MTEwNlQwMTQ3MzZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YzQ5YjBjODc1YTJhNjFlNDZmMWNhMmQwMjExNWNlNzMwNzI1OWE4YmIwOGM4MjBjMDRlNTIxY2YwZGVkN2JkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.L6gtgbANpd10V92WVQd_0OYm45K0sPwH6Kt-RfDYJsQ
https://private-user-images.githubusercontent.com/236466140/655363830-c695f462-f74a-4902-98a9-a966a6521e0f.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoic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RSzRaQSUyRjIwMjYxMTA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MTEwNlQwMTQ3MzZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jYjUyMWMwNDE2MTNiMTZmNmE0NTI2NWFiZTgwMjg3MGQwOWIxOGNkOTk1ZTQ2MDVjN2FhM2Y3NjU4YjFkZGM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.JH0et72wFbZV1TJo2RVQTC11W-PbTn1aT3mxFjEvfYs
nodejs-github-bothttps://github.com/nodejs-github-bot
on Sep 26, 2026https://github.com/nodejs/node/issues/66156#event-31901715859
zlib: preserve brotli params and dictionary on resethttps://github.com/nodejs/node/commit/1e0167d7d60b3b3de5be4a80d164fd4bf990acd3
1e0167dhttps://github.com/nodejs/node/commit/1e0167d7d60b3b3de5be4a80d164fd4bf990acd3
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66157https://github.com/nodejs/node/pull/66157
on Sep 26, 2026https://github.com/nodejs/node/issues/66156#event-31901715911
aduh95https://github.com/aduh95
on Sep 27, 2026https://github.com/nodejs/node/issues/66156#event-31936996739
zlib: preserve brotli params and dictionary on resethttps://github.com/nodejs/node/commit/a04f4cc0a08671ad2e32426244e01b9bbecc5b9e
a04f4cchttps://github.com/nodejs/node/commit/a04f4cc0a08671ad2e32426244e01b9bbecc5b9e
HoonDongKanghttps://github.com/HoonDongKang
on Sep 28, 2026https://github.com/nodejs/node/issues/66156#event-31971107942
zlib: preserve brotli params and dictionary on resethttps://github.com/HoonDongKang/node/commit/c2f95097979ef2f6e065cd78cd44ac8239f3f883
c2f9509https://github.com/HoonDongKang/node/commit/c2f95097979ef2f6e065cd78cd44ac8239f3f883
aduh95https://github.com/aduh95
on Sep 28, 2026https://github.com/nodejs/node/issues/66156#event-32031890318
zlib: preserve brotli params and dictionary on resethttps://github.com/nodejs/node/commit/6c927c0009a40c59e1ae9adf7429d109020434c4
6c927c0https://github.com/nodejs/node/commit/6c927c0009a40c59e1ae9adf7429d109020434c4
aduh95https://github.com/aduh95
on Oct 23, 2026https://github.com/nodejs/node/issues/66156#event-34094383039
zlib: preserve brotli params and dictionary on resethttps://github.com/nodejs/node/commit/87ae483e7f5c7a9f3cbfe487039f8992e4e28804
87ae483https://github.com/nodejs/node/commit/87ae483e7f5c7a9f3cbfe487039f8992e4e28804
zlib: preserve brotli params and dictionary on resethttps://github.com/nodejs/node/commit/41ca0e847326c6a116fa1b6ab277d0d8ccef2d4d
41ca0e8https://github.com/nodejs/node/commit/41ca0e847326c6a116fa1b6ab277d0d8ccef2d4d
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66156
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66156
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.