Skip to content

fix(zlib): prevent zip from degrading default compression - #11020

Closed
proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:fix/10810-gzip-default-level
Closed

proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:fix/10810-gzip-default-level

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Configure zip to keep its existing codec set without forcing flate2's zlib-rs backend across the combined Perry build.
  • Keep node:zlib on flate2's intended Rust backend, restoring the default gzip ratio from about 31 KiB to about 16 KiB for the issue's 4 MiB payload.
  • Add a product-level regression fixture covering gzipSync, callback gzip, and promisify(gzip).

Closes #10810.

Cause

The zip crate's default deflate feature enables deflate-flate2-zlib-rs. Cargo feature unification applied that backend to perry-ext-zlib in a combined build. At default level 6, the issue payload compressed to 31,388 bytes with that backend and 16,592 bytes with flate2's normal Rust backend.

Verification

  • Built perry, perry-runtime-static, perry-stdlib-static, and perry-ext-zlib in one Cargo invocation.
  • Compiled and ran test_gap_10810_zlib_default_compression.ts with the rebuilt Perry binary: all three compression checks printed true.
  • Ran the fixture with Node 26: all three checks printed true.
  • cargo test --profile perry-dev -p perry update_checker -- --nocapture (22 passed, including ZIP extraction and corrupt/archive traversal rejection)
  • Verified the perry feature graph contains flate2 rust_backend/miniz_oxide and no zlib-rs.
  • cargo fmt --all -- --check
  • bash scripts/check_file_size.sh
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Improved default gzip and deflate compression so outputs retain expected compression efficiency when using the CLI.
    • Preserved ZIP archive codec support while preventing compression backend conflicts.
    • Added regression coverage for synchronous, callback-based, and promisified gzip operations.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 003c3c0a-8bed-41ac-bec1-a86f5f1f6589

📥 Commits

Reviewing files that changed from the base of the PR and between 57a6d60 and f00c854.

📒 Files selected for processing (3)
  • changelog.d/11020-zlib-default-compression.md
  • crates/perry/Cargo.toml
  • test-files/test_gap_10810_zlib_default_compression.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The ZIP dependency now uses a backend-neutral flate2 feature configuration. A regression test checks gzip output from synchronous, callback, and promisified APIs. The changelog documents the fix.

Changes

zlib compression backend

Layer / File(s) Summary
Select the flate2 backend
crates/perry/Cargo.toml
The ZIP dependency disables default features and enables an explicit codec set with deflate-flate2.
Validate gzip output
test-files/test_gap_10810_zlib_default_compression.ts, changelog.d/11020-zlib-default-compression.md
The test checks that three gzip call forms produce output below 3,000 bytes. The changelog records the compression fix and regression coverage.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to f00c8

The change restores compact gzip behavior and adds effective regression coverage; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately describes the main change: preventing the zip dependency from degrading default zlib compression.
Description check ✅ Passed The description is mostly complete. It explains the change, cause, linked issue, verification steps, affected APIs, and test results. It uses a "Verification" section instead of the template's "Test p…
Linked Issues check ✅ Passed The changes satisfy #10810. crates/perry/Cargo.toml removes the feature-unifying zip.workspace dependency and selects deflate-flate2 with the existing codec set. This keeps node:zlib on the in…
Out of Scope Changes check ✅ Passed The changed files stay within #10810. The Cargo dependency change fixes backend selection, the fixture provides regression coverage for all affected call forms, and the changelog documents the fix. No…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main in merge train 260 (#11085), released as v0.5.1643 at d8f24f15ed.

Cherry-picked from this PR's head f00c8545fc and validated as one tree — CI 22/22 green, all 6 gap-suite shards. A train rebase gives the commits new SHAs, so GitHub cannot auto-close the source PR; closing by hand.

Nothing needed from you. Thanks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zlib: gzipSync and callback gzip regressed to 31,388 bytes where node gives 16,607 — #10308 closed by its good arms getting worse

1 participant