Skip to content

fix(test): compare proxy-agent headers as plain objects - #6122

Open
mcollina wants to merge 1 commit into
mainfrom
fix/proxy-agent-node27-headers
Open

mcollina wants to merge 1 commit into
mainfrom
fix/proxy-agent-node27-headers

Conversation

@mcollina

Copy link
Copy Markdown
Member

This relates to...

Fixes nodejs/citgm#1227

Rationale

Node 27 changed node:http req.headers to be a null-prototype object. Because assert.deepStrictEqual compares prototypes, the whole-header-object assertions in test/proxy-agent.js fail on Node 27. The failure is thrown inside the server request handler before the server and proxy are closed, which leaves handles open and hangs the test process until citgm's timeout.

Changes

Compare req.headers as a plain object in the ProxyAgent fetch header assertions.

Bug Fixes

ProxyAgent header assertions now pass on Node 27 instead of failing and hanging the test run.

Breaking Changes and Deprecations

N/A

Status

Node 27 changed node:http req.headers to a null-prototype object. Since
assert.deepStrictEqual compares prototypes, the whole-header-object
assertions in test/proxy-agent.js fail on Node 27. The throw occurs inside
the server request handler before the server/proxy are closed, which leaves
handles open and hangs the test process until the citgm timeout.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter

codecov-commenter commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (1b7b18e) to head (88e2b2a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6122      +/-   ##
==========================================
+ Coverage   91.61%   91.66%   +0.05%     
==========================================
  Files         113      113              
  Lines       44069    44041      -28     
==========================================
- Hits        40374    40371       -3     
+ Misses       3695     3670      -25     

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

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I ran node --test test/proxy-agent.js on 88e2b2a with Node 24.22.1 on Windows: 43 tests passed. I also used a null-prototype header object as a control: deepStrictEqual(headers, plainObject) fails as described, while deepStrictEqual({ ...headers }, plainObject) passes. All three changed assertions normalize only for comparison, so request headers are left untouched. I did not run Node 27 locally.

This branch has not been deployed

No deployments
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.

undici@8.12.3 fails in Node.js 27 Alpha with timeout

3 participants