Skip to content

feat!: enable h2 by default#4823

Closed
metcoder95 wants to merge 21 commits intonextfrom
enable_h2
Closed

feat!: enable h2 by default#4823
metcoder95 wants to merge 21 commits intonextfrom
enable_h2

Conversation

@metcoder95
Copy link
Member

@metcoder95 metcoder95 commented Feb 12, 2026

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

domenic and others added 21 commits January 31, 2026 09:25
When a MockAgent had a delayed response and the request was aborted via
AbortSignal, the delayed response callback would still fire and attempt to
call handler methods after onError had been called. This violated state
invariants expected by handlers like DecoratorHandler (used by decompress
interceptor).

The fix:
- Tracks abort state in mockDispatch
- Clears pending setTimeout timer when abort is called
- Checks abort flag in handleReply before invoking handler callbacks
- Properly calls handler.onConnect to register abort callback

Fixes #4693
In cases where onParserTimeout is called with a weak reference that has
already been collected it was throwing an error like:

    Cannot destructure property 'socket' of 'parser.deref(...)' as it is
    undefined

- Fixes #4755
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.0.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@2028fbc...6044e13)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: error stream instead of canceling

Co-authored-by: Matteo Collina <hello@matteocollina.com>

* fixup

---------

Co-authored-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Updated code block syntax highlighting from 'mjs' to 'js' so that syntax highlighting works.
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.25.12 to 0.27.3.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](evanw/esbuild@v0.25.12...v0.27.3)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.27.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ronag
ronag previously approved these changes Feb 12, 2026
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (2453caf) to head (09862a2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4823      +/-   ##
==========================================
- Coverage   93.17%   93.16%   -0.02%     
==========================================
  Files         109      109              
  Lines       34187    34187              
==========================================
- Hits        31855    31849       -6     
- Misses       2332     2338       +6     

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

@mcollina mcollina changed the base branch from main to next February 12, 2026 22:11
@mcollina mcollina dismissed ronag’s stale review February 12, 2026 22:11

The base branch was changed.

@mcollina
Copy link
Member

ahum, didn't work as expected.

@metcoder95
Copy link
Member Author

I think it needs a rebase, let me give it a shot

@metcoder95
Copy link
Member Author

Closed in favor of #4828

@metcoder95 metcoder95 closed this Feb 13, 2026
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.