Skip to content

zlib: avoid mutable push in sync output collection - #67748

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:zlib-sync-output-no-push
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:zlib-sync-output-no-push

Conversation

@rozzilla

@rozzilla rozzilla commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This follows the suggestion in #67456 (comment) to protect code that intentionally doesn't use primordials (node:zlib is listed in doc/contributing/primordials.md) by replacing user-mutable .push() with indexed assignments.
The new test covers both paths.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Nov 24, 2026
processChunkSync() and processSyncWithDefaults() collected output
chunks with buffers.push(), which looks up Array.prototype.push at call
time. Replacing that method from user code changed how synchronous zlib
calls such as gunzipSync() collected their output. Use indexed
assignments instead.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla
rozzilla force-pushed the zlib-sync-output-no-push branch from ca096e5 to f12c2b2 Compare November 24, 2026 13:15
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.54%. Comparing base (e7db489) to head (f12c2b2).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67748      +/-   ##
==========================================
- Coverage   90.55%   90.54%   -0.01%     
==========================================
  Files         803      803              
  Lines      285111   285110       -1     
  Branches    55039    55029      -10     
==========================================
- Hits       258186   258164      -22     
- Misses      17080    17097      +17     
- Partials     9845     9849       +4     
Files with missing lines Coverage Δ
lib/zlib.js 98.41% <100.00%> (ø)

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Renegade334 Renegade334 Nov 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but there's no need to add tests for any of these PRs, we aren't committed to this as an invariant and it just adds to the test burden.

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

Labels

needs-ci PRs that need a full CI run. 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