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

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)

BeforeAfter
zlib.Gzip() works with DEP0184 warningThrows TypeError
new zlib.Gzip()Unchanged
zlib.createGzip()Unchanged
Compression/decompression outputUnchanged

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
anonrigforce-pushed the zlib-class-syntax-eol-dep0184 branch from f7c3750 to 920a4feCompareJuly 30, 2026 19:11
@nodejs-github-botnodejs-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
anonrigforce-pushed the zlib-class-syntax-eol-dep0184 branch from 920a4fe to cdbe481CompareJuly 30, 2026 19:32
@anonriganonrig 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 mcollinaJuly 30, 2026 19:59
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

codecovBot 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 6 commits behind head on main.

Files with missing linesPatch %Lines
lib/zlib.js96.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 linesCoverage Δ
lib/zlib.js98.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.

@Renegade334Renegade334 added the deprecations Issues and PRs related to deprecations. label Jul 30, 2026
@anonrig

Copy link
Copy Markdown
MemberAuthor

cc @nodejs/tsc this is a semver-major change and requires more TSC reviews

@anonriganonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 31, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 31, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina left a comment

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

This would make backporting really hard, I'm not sure this is worth it, but ok.

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

Labels

deprecationsIssues and PRs related to deprecations.needs-ciPRs that need a full CI run.semver-majorPRs that contain breaking changes and should be released in the next major version.zlibIssues and PRs related to the zlib subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@anonrig@nodejs-github-bot@mcollina@panva@avivkeller@AugustinMauroy@Renegade334