Skip to content

zlib: convert classes to modern syntax and eol DEP0184 - #64849

Open
anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:zlib-class-syntax-eol-dep0184
Open

zlib: convert classes to modern syntax and eol DEP0184#64849
anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:zlib-class-syntax-eol-dep0184

Conversation

@anonrig

@anonrig anonrig commented Jul 30, 2026

Copy link
Copy Markdown
Member

Description

Convert the remaining node:zlib stream constructors (ZlibBase, Zlib, Deflate/Inflate/Gzip family, and Brotli) to ES6 class syntax, matching the earlier Zstd conversion.

Calling these constructors without new is End-of-Life for DEP0184. Use new or the create* factory helpers instead.

Why

DEP0184 has been a runtime deprecation since v24.0.0 (documentation-only since v22.9.0 / v20.18.0). Converting to class syntax both modernizes the implementation and hard-enforces the requirement for new.

Behavior change (semver-major)

Before After
zlib.Gzip() works with DEP0184 warning Throws TypeError
new zlib.Gzip() Unchanged
zlib.createGzip() Unchanged
Compression/decompression output Unchanged

Changes

  • lib/zlib.js: convert constructors to class / extends; drop deprecateInstantiation / ObjectSetPrototypeOf inheritance setup
  • doc/api/deprecations.md: mark DEP0184 as End-of-Life
  • Tests: require new, assert without-new throws, update subclass example to class syntax

Test plan

  • python3 tools/test.py all 65 test/parallel/test-zlib* tests — all pass
  • Smoke: gzip/brotli/zstd roundtrip with new and *Sync helpers
  • Smoke: without-new throws TypeError
  • make lint-js / make lint-md

Refs: #55718
Refs: #54708

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/userland-migrations

@anonrig
anonrig force-pushed the zlib-class-syntax-eol-dep0184 branch from f7c3750 to 920a4fe Compare July 30, 2026 19:11
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib subsystem. labels Jul 30, 2026
Convert ZlibBase, Zlib, and the remaining zlib/Brotli stream
constructors to ES6 class syntax. Calling these constructors without
`new` is no longer supported (DEP0184 End-of-Life); use `new` or the
create* factory helpers instead.

This is a semver-major change: code that relied on `zlib.Gzip()`
(without `new`) will now throw TypeError. The createGzip/createDeflate
helpers and all documented `new`-based usage remain unchanged. The
wire behavior and public options are preserved.

Refs: nodejs#55718
Refs: nodejs#54708
Assisted-by: Grok
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
@anonrig
anonrig force-pushed the zlib-class-syntax-eol-dep0184 branch from 920a4fe to cdbe481 Compare July 30, 2026 19:32
@anonrig anonrig added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 30, 2026
@anonrig
anonrig requested review from a team, marco-ippolito and mcollina July 30, 2026 19:59
Comment thread doc/api/deprecations.md
Instantiating classes without the `new` qualifier exported by the `node:zlib` module is deprecated.
It is recommended to use the `new` qualifier instead. This applies to all Zlib classes, such as `Deflate`,
`DeflateRaw`, `Gunzip`, `Inflate`, `InflateRaw`, `Unzip`, and `Zlib`.
Instantiating classes without the `new` qualifier exported by the `node:zlib` module is no longer

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.

can we have small before/after code example

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.45161% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (f9e2fe0) to head (cdbe481).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/zlib.js 96.45% 9 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #64849   +/-   ##
=======================================
  Coverage   90.15%   90.16%           
=======================================
  Files         746      746           
  Lines      242778   242722   -56     
  Branches    45747    45741    -6     
=======================================
- Hits       218878   218846   -32     
+ Misses      15378    15366   -12     
+ Partials     8522     8510   -12     
Files with missing lines Coverage Δ
lib/zlib.js 98.00% <96.45%> (-0.07%) ⬇️

... and 37 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.

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. semver-major PRs that contain breaking changes and should be released in the next major version. zlib Issues and PRs related to the zlib subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants