Skip to content

feat(http): implement zstd decompression for http adapter#6792

Merged
jasonsaayman merged 3 commits into
axios:v1.xfrom
BasixKOR:feat/zstd
May 19, 2026
Merged

feat(http): implement zstd decompression for http adapter#6792
jasonsaayman merged 3 commits into
axios:v1.xfrom
BasixKOR:feat/zstd

Conversation

@BasixKOR
Copy link
Copy Markdown
Contributor

@BasixKOR BasixKOR commented Feb 23, 2025

Instructions

CleanShot 2025-02-23 at 22 18 13@2x

Implement #6790. Mostly follows how the Brotli feature detection works, and updates the test code to add zstd test cases.

@BasixKOR BasixKOR changed the title feat: implement zstd compression for http adapter feat: implement zstd decompression for http adapter Feb 23, 2025
Comment thread lib/adapters/http.js Outdated
@umbrageodotus
Copy link
Copy Markdown

Updates?

@GuillaumeDecMeetsMore
Copy link
Copy Markdown

I’m wondering if we could move forward with this.
Node.js 24 is now in LTS and includes zstd support, which could benefit many users.
The PR scope is relatively small, so this could be a quick win.

@DigitalBrainJS DigitalBrainJS added the commit::feat The PR is related to a feature label Apr 24, 2026
@jasonsaayman jasonsaayman added status::changes-requested A reviewer requested changes to the PR priority::medium A medium priority status::needs-rebase The PR requires a rebase labels Apr 29, 2026
@jasonsaayman
Copy link
Copy Markdown
Member

@BasixKOR, sorry it took me so long to get to this PR. For this to land, can you make the following changes:

  • Needs a rebase. The diff doesn't apply cleanly anymore:
    • The test file moved to tests/unit/adapters/http.test.js (note plural tests/ and .test.js suffix).
    • The Accept-Encoding headers.set(...) call is now wrapped across multiple lines in lib/adapters/http.js, so the single-line replacement won't apply.
    • The switch-case hunk has drifted; case 'br': is around line 829 now.
  • Guard the test fixture on isZstdSupported. Right now, const zstdCompress = util.promisify(zlib.zstdCompress) runs unconditionally at module load. On a Node build without zstd, zlib.zstdCompress is undefined and util.promisify(undefined) throws, which takes the entire http test file down rather than just skipping the zstd case. Conditionally adding the zstd entry to the fixtures object (or skipping the describe when !isZstdSupported) keeps CI green on older Node.
  • Once rebased onto the multi-line headers.set, the gzip, compress, deflate + (isBrotliSupported ? ', br' : '') + (isZstdSupported ? ', zstd' : '') expression is getting unwieldy with three flags. A ['gzip','compress','deflate', isBrotliSupported && 'br', isZstdSupported && 'zstd'].filter(Boolean).join(', ') would read more cleanly, but that's a style call happy either way.

@BasixKOR
Copy link
Copy Markdown
Contributor Author

Thanks for looking into this PR :) I'll get the branch sorted and let you know.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@BasixKOR BasixKOR changed the title feat: implement zstd decompression for http adapter feat(http): implement zstd decompression for http adapter Apr 30, 2026
@jasonsaayman
Copy link
Copy Markdown
Member

@BasixKOR is there a update here?

@BasixKOR
Copy link
Copy Markdown
Contributor Author

@jasonsaayman It's ready for review now :) I requested review again for you to look again.

@jasonsaayman
Copy link
Copy Markdown
Member

@BasixKOR, I added a gate, else I think conservatively we would need to actually make this a breaking change. Also added some testing updates.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@jasonsaayman jasonsaayman merged commit 2af5c5f into axios:v1.x May 19, 2026
24 checks passed
@DigitalBrainJS
Copy link
Copy Markdown
Collaborator

@jasonsaayman Probably, this flag should have been added to the transitional config, as it serves simply to protect against the introduction of a breaking change. Otherwise, we pollute the config with temporary parameters. For example, transitional.useZstd.

@jasonsaayman
Copy link
Copy Markdown
Member

jasonsaayman commented May 19, 2026

Thanks @DigitalBrainJS, yeah, true, I will make a change asap for that. Will also compound it as a rule in the contributing guide, as most contributors don't really do this. Since I used AI to make that change it makes sense it missed the nuance.

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

Labels

commit::feat The PR is related to a feature priority::medium A medium priority status::changes-requested A reviewer requested changes to the PR status::needs-rebase The PR requires a rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants