-
Type:
New Feature
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Compressors, zstd
Use Case
As a Node.js driver user,
I want zstd compression to use the built-in zstd support in Node.js,
so that I don't have to install additional npm packages for zstd compression to work.
User Experience
- On Node.js 22.15.0+ the driver uses the built-in zlib.zstdCompress / zlib.zstdDecompress. No @mongodb-js/zstd install is needed.
- On older Node.js versions the driver falls back to @mongodb-js/zstd, so existing setups keep working without changes.
- If neither is available, the MongoMissingDependencyError message now says that built-in zstd needs Node.js 22.15.0 or later and that @mongodb-js/zstd is the alternative.
Dependencies
- This is how MONGOSH-825 will be implemented.
Risks/Unknowns
- Built-in and addon output must stay interoperable, since the server and other clients decompress either one. Covered by tests in both directions.
- Compression level is passed through zlib.constants.ZSTD_c_compressionLevel. When no level is given, the built-in default is used.
Acceptance Criteria
Implementation Requirements
- getZstdLibrary() in src/deps.ts prefers the Node.js built-in implementation when both zlib.zstdCompress and zlib.zstdDecompress exist.
- Falls back to @mongodb-js/zstd when the built-in is unavailable.
- Precedence decision: the built-in wins when both are present.
Testing Requirements
- Data compressed by the built-in is decompressed by @mongodb-js/zstd, and the other way around.
- The built-in is preferred when both are present.
- The compression level is passed to the built-in implementation.
- Falls back to @mongodb-js/zstd when the built-in is unavailable.
Documentation Requirements
- README optional-dependencies list notes that @mongodb-js/zstd is only needed on Node.js earlier than 22.15.0.
Follow Up Requirements
- N/A
- blocks
-
MONGOSH-825 MongoParseError: zstd is not a valid compression mechanism
-
- Needs Triage
-
-
COMPASS-10538 Optional module `@mongodb-js/zstd` not found
-
- Waiting (Blocked)
-
- is depended on by
-
MONGOSH-825 MongoParseError: zstd is not a valid compression mechanism
-
- Needs Triage
-
- is duplicated by
-
NODE-7620 using build-in zstd on nodejs
-
- Closed
-
- is related to
-
COMPASS-10538 Optional module `@mongodb-js/zstd` not found
-
- Waiting (Blocked)
-
- related to
-
NODE-7678 zstd: replace prebuild-install with per-platform npm packages
-
- Backlog
-