Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation preserves fallback behavior and includes focused coverage for the new selection logic.
0 open findings
What changed in this PR
Adds native Node.js zstd support while retaining the optional package fallback.
Changes:
- Prefer built-in zstd compression and decompression when available.
- Add interoperability, preference, compression-level, and fallback tests.
- Document when
@mongodb-js/zstdis required.
| File | Description |
|---|---|
src/deps.ts |
Selects built-in zstd or the optional dependency. |
test/unit/cmap/wire_protocol/compression.test.ts |
Tests interoperability and implementation selection. |
test/mongodb_bundled.ts |
Exposes the loader to bundled tests. |
README.md |
Updates zstd dependency guidance. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
There was a problem hiding this comment.
By rewriting this test (and adding another way to do zstd compression) we might be changing the meaning of this string a little.
Should tests under this get a context of 'when the compression library is zlib'? And then, elsewhere, when the compression library is @mongodb-js/zstd?
There was a problem hiding this comment.
Thanks @seanrmilligan! I renamed them to "when the agreed compressor is zstd" to match the snappy/zlib tests in the same file. The idea is that these tests pass whichever implementation the driver picks: on Node 22.15+ the interop tests check the built-in against @mongodb-js/zstd in both directions, and the separate getZstdLibrary() tests check which implementation is picked.
Description
Summary of Changes
Use Node.js built-in zstd (
zlib.zstdCompress/zlib.zstdDecompress, Node.js 22.15.0+) when available, falling back to@mongodb-js/zstdotherwiseTests: interop with
@mongodb-js/zstdin both directions, built-in preferred when both are present, fallback when built-in is unavailableRelease Highlight
zstd compression no longer requires
@mongodb-js/zstdon Node.js 22.15.0+The driver now uses Node.js' built-in zstd implementation when it is available. On older Node.js versions it continues to use
@mongodb-js/zstd, so no changes are needed for existing setups.Thanks to @axelonet for the original contribution!
Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript