feat!: enable h2 by default by metcoder95 · Pull Request #4828 · nodejs/undici (original) (raw)
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: falsein 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: falsein their client configuration - The protocol upgrade is transparent and should not affect most applications, but may change connection behavior and performance characteristics
Status
- I have read and agreed to the Developer's Certificate of Origin
- Tested
- Benchmarked (optional)
- Documented
- Review ready
- In review
- Merge ready