Skip to content

fix(decompress): preserve response trailers#5572

Merged
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/decompress-preserve-trailers
Jul 20, 2026
Merged

fix(decompress): preserve response trailers#5572
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/decompress-preserve-trailers

Conversation

@Ram-blip

@Ram-blip Ram-blip commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This relates to...

No existing issue. This fixes response trailers being discarded by interceptors.decompress() after successful decompression.

Rationale

interceptors.decompress() delays response completion until the decompression stream finishes. Its completion callbacks previously forwarded an empty trailers object, causing valid HTTP response trailers to be lost.

The trailers received by onResponseEnd() must be retained across the asynchronous decompression boundary and forwarded when decompression completes.

Changes

  • Store normalized response trailers while decompression is finishing.
  • Forward trailers through both the single-decoder and chained-decoder completion paths.
  • Add regression coverage for gzip responses with trailers.
  • Extend the multiple-content-encoding test to verify trailer preservation.

Features

N/A

Bug Fixes

  • Preserve HTTP response trailers when using interceptors.decompress().
  • Preserve trailers for responses with multiple content encodings.

Breaking Changes and Deprecations

N/A

Status

Tests

node --test test/interceptors/decompress.js
npm run test:interceptors
npm run lint

Signed-off-by: Ram-blip <ramcruze2000@gmail.com>
@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (1383989) to head (a84de8f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5572   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files         110      110           
  Lines       37560    37563    +3     
=======================================
+ Hits        35108    35113    +5     
+ Misses       2452     2450    -2     

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

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollina
mcollina merged commit f36ea9c into nodejs:main Jul 20, 2026
38 checks passed
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