Skip to content

Conversation

@rambo-panda
Copy link

@rambo-panda rambo-panda commented Jan 16, 2026

This relates to...

#4737

Rationale

The Pool class was not passing the useH2c option to buildConnector and kOptions, causing HTTPParserError when using Agent with useH2c and connections > 1.

Changes

This fix ensures that:

  • useH2c is extracted from constructor parameters
  • useH2c is passed to buildConnector for proper connection setup
  • useH2c is included in kOptions for client instances

Features

N/A

Bug Fixes

Fixes issue with h2c (HTTP/2 Cleartext) failing on second connection when Pool creates multiple Client instances.

Breaking Changes and Deprecations

Before: connections > 1 with useH2c caused HTTP/1.1 parser to receive
HTTP/2 binary frames, resulting in protocol mismatch error
After: All connections properly use HTTP/2 cleartext protocol

Status

The Pool class was not passing the useH2c option to buildConnector
and kOptions, causing HTTPParserError when using Agent with useH2c
and connections > 1.

This fix ensures that:
- useH2c is extracted from constructor parameters
- useH2c is passed to buildConnector for proper connection setup
- useH2c is included in kOptions for client instances

Fixes issue with h2c (HTTP/2 Cleartext) failing on second connection
when Pool creates multiple Client instances.

Before: connections > 1 with useH2c caused HTTP/1.1 parser to receive
        HTTP/2 binary frames, resulting in protocol mismatch error
After:  All connections properly use HTTP/2 cleartext protocol

Fixes nodejs#4737
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Can you please add a unit test?

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.88%. Comparing base (250efc8) to head (c0df7b2).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4738      +/-   ##
==========================================
- Coverage   92.89%   92.88%   -0.01%     
==========================================
  Files         109      109              
  Lines       33886    33888       +2     
==========================================
  Hits        31478    31478              
- Misses       2408     2410       +2     

☔ View full report in Codecov by Sentry.
📢 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.

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