Skip to content

doc: clarify cumulative output limits for zlib streams - #67373

Open
sboettch wants to merge 1 commit into
nodejs:mainfrom
sboettch:doc-zlib-stream-max-output-length
Open

sboettch wants to merge 1 commit into
nodejs:mainfrom
sboettch:doc-zlib-stream-max-output-length

Conversation

@sboettch

Copy link
Copy Markdown

Refs: https://github.com/nodejs/node/blob/main/doc/api/zlib.md

Hello nodejs/node documentation maintainers, and thank you for maintaining the node:zlib API reference across gzip, brotli, and zstd. I am a citizen applied data scientist working on WebHealth (an open public-interest security observatory), and while testing streaming decompression configurations locally across Node.js runtimes, I noticed a small point in doc/api/zlib.md where clarifying how maxOutputLength interacts with streaming decompressors could help callers bound memory safely.

doc/api/zlib.md documents maxOutputLength under Class: Options, Class: BrotliOptions, and Class: ZstdOptions for single-buffer convenience methods (zlib.gunzip(), zlib.brotliDecompress(), zlib.zstdDecompress(), and their *Sync counterparts). On Node.js v22.x, v24.x, and v26.5.0, passing { maxOutputLength } to streaming factories (zlib.createGunzip(), zlib.createBrotliDecompress(), zlib.createZstdDecompress()) bounds per-chunk internal buffer growth rather than cumulative decoded stream output across chunks (RFC 1952 / RFC 7932 / RFC 8878, CWE-409).

Clarify in doc/api/zlib.md (Class: Options, Class: BrotliOptions, and Class: ZstdOptions) that maxOutputLength caps total output on convenience methods rather than cumulative stream output across create*Decompress() streams, and document a node:stream/promises pipeline() + Transform byte-counter pattern that aborts streaming decompression and destroys the upstream Readable as soon as a cumulative byte limit is exceeded.

Validation:

  • Verified doc/api/zlib.md line wrapping (<= 80 columns), reference links ([convenience methods][], [pipeline()][], [stream.Transform][]), and whitespace (git diff --check) with zero warnings.
  • Verified the documented pipeline() + Transform guard across createGunzip(), createBrotliDecompress(), and createZstdDecompress() at exact 65,536 B (OK) and 65,537 B (RangeError + source.destroyed === true).

Thank you very much for your time and review. If a shorter inline note under maxOutputLength or a different location in doc/api/zlib.md fits the documentation style better, I am happy to adjust this however you prefer.

Warm regards,
Sophia Boettcher

Clarify in `doc/api/zlib.md` that `maxOutputLength` bounds single-call
convenience methods (`zlib.gunzip()`, `zlib.brotliDecompress()`,
`zlib.zstdDecompress()`, and `*Sync` variants) rather than cumulative
decoded output across `create*Decompress()` streams, and add a
`stream/promises` `pipeline()` example enforcing a cumulative byte limit.

Signed-off-by: Sophia Boettcher <sboettcher@ub313.net>
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to Node.js documentation. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants