Skip to content

fix(decompress): stop inflating compress and x-compress - #5665

Open
luantaraschi wants to merge 1 commit into
nodejs:mainfrom
luantaraschi:fix/decompress-compress-is-not-deflate
Open

fix(decompress): stop inflating compress and x-compress#5665
luantaraschi wants to merge 1 commit into
nodejs:mainfrom
luantaraschi:fix/decompress-compress-is-not-deflate

Conversation

@luantaraschi

@luantaraschi luantaraschi commented Aug 7, 2026

Copy link
Copy Markdown

This relates to...

No open issue. Found while reading lib/interceptor/decompress.js.

Rationale

supportedEncodings maps compress and x-compress to createInflate:

deflate: createInflate,
compress: createInflate,
'x-compress': createInflate,

Those are different formats. RFC 9110 section 8.4.1.1 defines compress as the UNIX compress (LZW) format, while deflate is zlib. Node has no LZW decoder, so feeding a compress body to inflate cannot succeed. It does not degrade, it fails the request:

Z_DATA_ERROR: incorrect header check

fetch() does not do this. Its coding switch in lib/web/fetch/index.js handles x-gzip, gzip, deflate, br and zstd, and anything else falls through untouched. Same response, same server, both from this repo:

interceptor : Z_DATA_ERROR | incorrect header check
fetch       : "this body is not deflate data"

So composing the decompress interceptor onto a client turns a response that fetch reads fine into a hard failure.

The two entries are removed. compress and x-compress now take the path every other unrecognised coding already takes: #createDecompressionChain returns an empty chain, the body passes through, and Content-Encoding stays on the response since nothing was decoded. The only case this changes is a server that labels zlib data as compress, which is already mislabelled and which fetch never decoded either.

The doc line that advertised the two codings is updated to match.

Worth noting: this touches the same file as #5664, but a different region, so the two apply independently.

Changes

compress and x-compress removed from supportedEncodings, with a comment recording why.

docs/docs/api/Interceptors.md: the decompress section no longer lists the two codings and says unrecognised codings are left untouched.

Test added to test/interceptors/decompress.js: a Content-Encoding: compress response with a non-inflatable body arrives unchanged instead of erroring.

Features

N/A

Bug Fixes

A Content-Encoding: compress response no longer fails with Z_DATA_ERROR under the decompress interceptor.

Breaking Changes and Deprecations

A server sending zlib data labelled compress was being decoded and now is not. That labelling is already wrong per RFC 9110, and fetch() in this repo has never decoded it.

Status

RFC 9110 section 8.4.1.1 defines compress as the UNIX compress (LZW) format,
not zlib, so createInflate cannot read it. A compress-encoded response failed
with Z_DATA_ERROR instead of being passed through.

fetch() in this repo already handles only x-gzip, gzip, deflate, br and zstd
and leaves everything else alone. The two codings now take that same path,
and the docs are updated to match.
Copilot AI lite review requested due to automatic review settings August 7, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov-commenter

codecov-commenter commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.44%. Comparing base (dd85997) to head (7e2e500).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5665   +/-   ##
=======================================
  Coverage   93.43%   93.44%           
=======================================
  Files         110      110           
  Lines       38733    38778   +45     
=======================================
+ Hits        36190    36235   +45     
  Misses       2543     2543           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@luantaraschi

Copy link
Copy Markdown
Author

Quick note on the one red job here, in case it is what is holding this up.

The failure is test/http2-request-never-settles.js on Test with Node.js 24 on ubuntu-latest with WASM SIMD disabled, and it is the only failing test in that run. #5674 records it as a flake on main, with the root cause upstream in nodejs/node#64841, the Maglev SIGSEGV on Node >= v24.15.0. The signature matches what that PR describes: no TAP output, no subtests, and the file ending in 3.1s, well under the 15s watchdog.

This branch only touches lib/interceptor/decompress.js and its test, so there is no path from it into an HTTP/2 session. Running both files on this branch locally, on Node 22.20.0: test/interceptors/decompress.js 28 passing, and test/http2-request-never-settles.js 2 passing.

The branch is 6 commits behind main and predates #5674. Glad to rebase for a fresh run if that helps, just say the word.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants