Skip to content

feat!: enable h2 by default#4828

Merged
mcollina merged 1 commit intonextfrom
enable_h2_next
Mar 6, 2026
Merged

feat!: enable h2 by default#4828
mcollina merged 1 commit intonextfrom
enable_h2_next

Conversation

@metcoder95
Copy link
Member

This relates to...

This enables HTTP/2 support by default in Undici.

Rationale

Currently, users must explicitly opt-in to H2 support via allowH2: true. This change adjusts Undici's defaults to align with current web standards and improve out-of-the-box performance.

Changes

This PR changes the default value of the allowH2 option from false to true in the connection builder (lib/core/connect.js). When connecting to HTTPS servers, Undici will now use HTTP/2 if the server advertises it through ALPN negotiation, falling back to HTTP/1.1 if not supported.

Features

  • HTTP/2 is now enabled by default for connections to servers that support it via ALPN negotiation
  • Users can still explicitly disable H2 by setting allowH2: false in client options

Bug Fixes

N/A

Breaking Changes and Deprecations

Breaking Change: The default value of allowH2 changes from false to true.

Impact:

  • Applications relying on HTTP/1.1-only behavior by default will now use HTTP/2 when connecting to H2-capable servers
  • Users who need HTTP/1.1-only connections must now explicitly set allowH2: false in their client configuration
  • The protocol upgrade is transparent and should not affect most applications, but may change connection behavior and performance characteristics

Status

(cherry picked from commit 09862a2)
@metcoder95 metcoder95 mentioned this pull request Feb 13, 2026
7 tasks
@metcoder95 metcoder95 requested review from mcollina and ronag February 13, 2026 09:41
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (393094a) to head (b55ff3b).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #4828   +/-   ##
=======================================
  Coverage   93.26%   93.26%           
=======================================
  Files         107      107           
  Lines       34031    34031           
=======================================
  Hits        31738    31738           
  Misses       2293     2293           

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

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.

lgtm

@mcollina
Copy link
Member

@metcoder95 can you look into the failure? It seems relevant.

@mcollina mcollina added the semver-major Features or fixes that will be included in the next semver major release label Feb 21, 2026
@mcollina mcollina merged commit 1918731 into next Mar 6, 2026
31 of 33 checks passed
@mcollina mcollina deleted the enable_h2_next branch March 6, 2026 15:38
@mcollina mcollina mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-major Features or fixes that will be included in the next semver major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants