Skip to content

feat(NODE-7097): adopt built-in zstd support#4890

Open
axelonet wants to merge 1 commit intomongodb:mainfrom
axelonet:NODE-7097-built-in-zstd
Open

feat(NODE-7097): adopt built-in zstd support#4890
axelonet wants to merge 1 commit intomongodb:mainfrom
axelonet:NODE-7097-built-in-zstd

Conversation

@axelonet
Copy link
Copy Markdown

@axelonet axelonet commented Mar 13, 2026

Description

Summary of Changes

  • Prefer Node.js built-in zstd support when available
  • Fall back to @mongodb-js/zstd when built-in support is unavailable
  • Update zstd compression tests to cover driver round-tripping and optional dependency behavior

Release Highlight

Release notes highlight

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@axelonet axelonet requested a review from a team as a code owner March 13, 2026 11:01
@dariakp dariakp added tracked-in-jira Ticket filed in MongoDB's Jira system External Submission PR submitted from outside the team labels Mar 17, 2026
@PavelSafronov
Copy link
Copy Markdown
Contributor

@axelonet , thanks so much for your contribution. The team will triage this PR and https://jira.mongodb.org/browse/NODE-7097 and will get back to you.

@sarthaksoni25
Copy link
Copy Markdown

Hi, I'm new to this codebase and have been reading through some open PRs to learn, this one caught my attention. Please correct me if I'm misreading anything.

  • On the test in optional_require.test.ts - the new test covers the case where the addon is absent and built-in is used instead. But since CI explicitly installs @mongodb-js/zstd via run-tests.sh, this test would always skip there. The priority behaviour i.e. built-in preferred over addon when both are present, doesn't seem to have test coverage. Is that intentional?

  • On the compression test in compression.test.ts - I'm new to zstd so correct me if I'm wrong. Reading through the code, it looks like on Node 22.15.0+ both compress() and decompress() end up using the same built-in implementation. Doesn't that make the round-trip test self-referential? I see zstd frames always start with magic bytes 0xFD2FB528 per the spec, would checking those bytes be a simpler independent verification?

Happy to be corrected.

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

Labels

External Submission PR submitted from outside the team tracked-in-jira Ticket filed in MongoDB's Jira system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants