fix(pool): add useH2c option support for multiple connections#4738
Open
rambo-panda wants to merge 1 commit intonodejs:mainfrom
Open
fix(pool): add useH2c option support for multiple connections#4738rambo-panda wants to merge 1 commit intonodejs:mainfrom
rambo-panda wants to merge 1 commit intonodejs:mainfrom
Conversation
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
mcollina
requested changes
Jan 19, 2026
Member
mcollina
left a comment
There was a problem hiding this comment.
Thanks for opening a PR! Can you please add a unit test?
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:
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