GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(decompress): join a repeated content-encoding header by luantaraschi · Pull Request #5664 · nodejs/undici

Conversation

@luantaraschi

@luantaraschi luantaraschi commented Aug 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This relates to...

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

Rationale

DecompressHandler.onResponseStart reads the header as a string:

const contentEncoding = headers['content-encoding']
...
const decompressors = this.#createDecompressionChain(contentEncoding.toLowerCase())

parseHeaders turns a repeated field into an array (lib/core/util.js, the val = [val] branch), and the JSDoc on this very method already types headers as Record<string, string | string[] | undefined>. An array is truthy, so #shouldSkipDecompression lets it through and .toLowerCase() throws:

TypeError: contentEncoding.toLowerCase is not a function

Reproduced against a raw socket server that writes the field twice:

HTTP/1.1 200 OK
Content-Type: text/plain
Content-Encoding: gzip
Content-Encoding: gzip

RFC 9110 section 5.3 lets a recipient combine repeated field lines into one by joining the values with commas, and that comma-joined form is exactly what #createDecompressionChain already splits and handles. So the fix is to join before anything else looks at the value.

The existing chain limit still applies afterwards: six repeated Content-Encoding lines join into six parts and hit the same maxContentEncodings guard as the single-line form, which the suite already covers.

Changes

onResponseStart joins an array-valued content-encoding with commas before the skip check and the chain build.

Test added to test/interceptors/decompress.js: a response with two Content-Encoding: gzip lines and a doubly gzipped body decompresses to the original text.

Features

N/A

Bug Fixes

The decompress interceptor no longer throws a TypeError when a response repeats Content-Encoding across field lines, and decompresses it the same way it decompresses the comma-joined single-line form.

Breaking Changes and Deprecations

None. Responses with a single Content-Encoding line take exactly the same path as before.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested
  • Benchmarked (optional)
  • Documented
  • Review ready
  • In review
  • Merge ready

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@luantaraschi
fix(decompress): join a repeated content-encoding header
29a9c1c
parseHeaders turns a repeated field into an array, and this method's own
JSDoc already types the headers record as string | string[] | undefined.
An array is truthy, so the skip check let it through and toLowerCase threw
a TypeError.

RFC 9110 section 5.3 allows joining repeated field lines with commas, which
produces the single-line form the decompression chain already splits and
handles, including the maxContentEncodings guard.
Copilot AI lite review requested due to automatic review settings August 7, 2026 16:54
Copilot AI reviewed Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@luantaraschi luantaraschi mentioned this pull request Aug 7, 2026
fix(decompress): stop inflating compress and x-compress #5665
Merged
4 of 7 tasks
metcoder95
metcoder95 approved these changes Aug 14, 2026
View reviewed changes
@codecov-commenter

codecov-commenter commented Aug 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 (29a9c1c).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5664   +/-   ##
=======================================
  Coverage   93.43%   93.44%           
=======================================
  Files         110      110           
  Lines       38733    38782   +49     
=======================================
+ Hits        36190    36239   +49     
  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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina merged commit a975197 into nodejs:main Sep 4, 2026
38 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
[Release] v8.11.0 #5821
Closed
This was referenced Sep 21, 2026
[Release] v8.11.0 #5848
Closed
[Release] v8.11.0 #5849
Merged
@mrityunjay-pandey mrityunjay-pandey mentioned this pull request Oct 15, 2026
[v7.x] fix(decompress): join a repeated content-encoding header (#5664) #6026
Merged
3 of 7 tasks
mcollina pushed a commit that referenced this pull request Oct 17, 2026
@mrityunjay-pandey @luantaraschi
fix(decompress): join a repeated content-encoding header (#5664) (#6026)
14c296f
parseHeaders turns a repeated field into an array, and this method's own
JSDoc already types the headers record as string | string[] | undefined.
An array is truthy, so the skip check let it through and toLowerCase threw
a TypeError.

RFC 9110 section 5.3 allows joining repeated field lines with commas, which
produces the single-line form the decompression chain already splits and
handles, including the maxContentEncodings guard.

(cherry picked from commit a975197)

Co-authored-by: Luan Taraschi <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
[Release] v7.30.2 #6163
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@metcoder95 metcoder95 metcoder95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@luantaraschi @codecov-commenter @metcoder95 @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.