Title: zstd decoding complete frame in read stream halts stream · Issue #64741 · nodejs/node · GitHub
Open Graph Title: zstd decoding complete frame in read stream halts stream · Issue #64741 · nodejs/node
X Title: zstd decoding complete frame in read stream halts stream · Issue #64741 · nodejs/node
Description: Version v26.5.0 Platform Darwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041 arm64 Subsystem No response What steps will reproduce the bug? import { Buffer ...
Open Graph Description: Version v26.5.0 Platform Darwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041 arm64 Subsystem No response What steps ...
X Description: Version v26.5.0 Platform Darwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041 arm64 Subsystem No response What steps ...
Opengraph URL: https://github.com/nodejs/node/issues/64741
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"zstd decoding complete frame in read stream halts stream","articleBody":"### Version\n\nv26.5.0\n\n### Platform\n\n```text\nDarwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041 arm64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\n```js\nimport { Buffer } from 'node:buffer';\nimport * as consumers from 'node:stream/consumers';\nimport * as zlib from 'node:zlib';\n\nfunction consume(codec, writes) {\n\tconst inflate = codec.createDecompress();\n\tconst result = consumers.buffer(inflate);\n\twrites.forEach(write => inflate.write(write));\n\tinflate.end();\n\treturn result;\n}\n\nfunction describe(buffer) {\n\tconst aa = buffer.includes(0x41);\n\tconst bb = buffer.includes(0x42);\n\tconst which = function() {\n\t\tif (aa && bb) {\n\t\t\treturn 'frameA + frameB';\n\t\t} else if (aa) {\n\t\t\treturn 'frameA only';\n\t\t} else if (bb) {\n\t\t\treturn 'frameB only';\n\t\t} else {\n\t\t\treturn 'nothing';\n\t\t}\n\t}();\n\treturn `${buffer.length} bytes (${which})`;\n}\n\nasync function attempt(codec, writes) {\n\ttry {\n\t\treturn describe(await consume(codec, writes));\n\t} catch (error) {\n\t\treturn `threw: ${error.message}`;\n\t}\n}\n\nconst tests = [ {\n\tname: 'zstd',\n\tcompress: buffer => zlib.zstdCompressSync(buffer),\n\tcreateDecompress: () => zlib.createZstdDecompress(),\n}, {\n\tname: 'gzip',\n\tcompress: buffer => zlib.gzipSync(buffer),\n\tcreateDecompress: () => zlib.createGunzip(),\n} ];\n\nconsole.log(`node ${process.version}`);\nfor (const codec of tests) {\n\t// 'A' / 'B'\n\tconst frameA = codec.compress(Buffer.alloc(2000, 0x41));\n\tconst frameB = codec.compress(Buffer.alloc(2000, 0x42));\n\tconst concatenated = Buffer.concat([ frameA, frameB ]);\n\n\t// BUG: both frames in a single write — the boundary between them falls inside one input buffer.\n\tconst bug = await attempt(codec, [ concatenated ]);\n\t// COUNTER-EXAMPLE: the same two frames, one per write — the boundary lands at a write boundary.\n\tconst counter = await attempt(codec, [ frameA, frameB ]);\n\n\tconsole.log(`${codec.name}:`);\n\tconsole.log(` stream, both frames in ONE write -> ${bug}`);\n\tconsole.log(` stream, one frame per write -> ${counter}`);\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nThis reproduces every time\n\n### What is the expected behavior? Why is that the expected behavior?\n\nDecoding concatenated zstd payloads should decode correctly as one stream. Indeed, `zstdcat` will decode this correctly (omitted from example but you can take my word for it).\n\n### What do you see instead?\n\n```\nmarcel[1:42:21PM] [~/xx] ~/Downloads/node-v26.5.0-darwin-arm64/bin/node a.mjs\nnode v26.5.0\nzstd:\n stream, both frames in ONE write -> 2000 bytes (frameA only)\n stream, one frame per write -> 4000 bytes (frameA + frameB)\ngzip:\n stream, both frames in ONE write -> 4000 bytes (frameA + frameB)\n stream, one frame per write -> 4000 bytes (frameA + frameB)\n```\n\n### Additional information\n\nThis will cause spurious failures while decoding zstd streams. The odds of it happening are a function of stream read size vs zstd chunk size. In my case I ran into this while decoding a stream after about 3GB and tracked it down to this bug.","author":{"url":"https://github.com/laverdet","@type":"Person","name":"laverdet"},"datePublished":"2026-07-25T18:45:40Z","url":"https://github.com/nodejs/node/issues/64741"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b42a844-e2c2-1d91-5d94-d1a9237e950d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5AE:D9695:3F43E0:5235B1:6AED2103 |
| html-safe-nonce | f741179880fef6343a2b57d71efdc5568d43256f6a720494c8a8c2e7bb07b3bf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUFFOkQ5Njk1OjNGNDNFMDo1MjM1QjE6NkFFRDIxMDMiLCJ2aXNpdG9yX2lkIjoiNDE0MzY1NzAyMTU5MDAyMDM1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 788c939cf9a749f1df3352a70e0f22124e88ab9c64c914d9b3e5fb2f88080ac4 |
| hovercard-subject-tag | issue:4977181748 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64741/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ab10331ea8d60d5c3671bb3940fd0aa8c9be4485f5575ef03cf5e2d8587419d6/nodejs/node/issues/64741 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ab10331ea8d60d5c3671bb3940fd0aa8c9be4485f5575ef03cf5e2d8587419d6/nodejs/node/issues/64741 |
| og:image:alt | Version v26.5.0 Platform Darwin Mac.lan 24.6.0 Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041 arm64 Subsystem No response What steps ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | laverdet |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width