Skip to content

fix: handle invalid HTTP/2 connection headers (#4356)#5101

Merged
metcoder95 merged 1 commit intomainfrom
fix/http2-invalid-connection-headers-4356
Apr 24, 2026
Merged

fix: handle invalid HTTP/2 connection headers (#4356)#5101
metcoder95 merged 1 commit intomainfrom
fix/http2-invalid-connection-headers-4356

Conversation

@mcollina
Copy link
Copy Markdown
Member

Summary

  • catch ERR_HTTP2_INVALID_CONNECTION_HEADERS from session.request() in the HTTP/2 client
  • wrap the Node.js error in InformationalError and preserve the original error as cause
  • tear down the broken HTTP/2 session so queued requests can continue on a fresh connection
  • add an HTTP/2 regression test covering both catchable failure and queue recovery

Fixes #4356

Testing

  • npx eslint lib/core/errors.js lib/dispatcher/client-h2.js test/http2-invalid-connection-headers.js
  • npx borp -p "test/http2-invalid-connection-headers.js"
  • npm run test:h2:core
  • npm run test:h2:fetch

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.12%. Comparing base (e1211a5) to head (6e31782).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
lib/dispatcher/client-h2.js 94.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5101      +/-   ##
==========================================
+ Coverage   93.10%   93.12%   +0.01%     
==========================================
  Files         110      110              
  Lines       35788    35860      +72     
==========================================
+ Hits        33322    33394      +72     
  Misses       2466     2466              

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

@metcoder95 metcoder95 merged commit 332a3b6 into main Apr 24, 2026
35 checks passed
@metcoder95 metcoder95 deleted the fix/http2-invalid-connection-headers-4356 branch April 24, 2026 09:04
Comment on lines +498 to +500
if (err?.code !== 'ERR_HTTP2_INVALID_CONNECTION_HEADERS') {
throw err
}
Copy link
Copy Markdown

@webcarrot webcarrot Apr 24, 2026

Choose a reason for hiding this comment

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

@mcollina how users will be able to catch non ERR_HTTP2_INVALID_CONNECTION_HEADERS errors in context of #4356 ?

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.

Invalid HTTP2 headers should be recoverable

4 participants