feat(client): add ClientBuilder::happy_eyeballs_timeout option - #3081
Open
jeffyaw wants to merge 1 commit into
Open
feat(client): add ClientBuilder::happy_eyeballs_timeout option#3081jeffyaw wants to merge 1 commit into
jeffyaw wants to merge 1 commit into
Conversation
Expose hyper-util's HttpConnector::set_happy_eyeballs_timeout through the async and blocking client builders, so users can tune or disable the RFC 6555 dual-stack fallback delay (default 300ms). Closes seanmonstar#1318 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
feat(client): add
ClientBuilder::happy_eyeballs_timeoutoptionWhat
Exposes hyper-util's
HttpConnector::set_happy_eyeballs_timeouton both theasync and blocking
ClientBuilder:Nonedisables the parallel fallback entirely (addresses are triedsequentially); the default stays at hyper-util's 300ms, so behavior is
unchanged for existing users. The plumbing follows the exact shape of
tcp_user_timeout(#2724) and the TCP keepalive options (#2675): aConfigfield in
src/async_impl/client.rs, a setter onConnectorBuilderinsrc/connect.rsthat forwards to the underlyingHttpConnectorin all threeTLS variants, and a
with_innermirror insrc/blocking/client.rs.Why
hyper-util's 300ms default is a real, measurable tax on dual-stack hosts
where the preferred family does not answer:
localhostwhere the server is boundonly to
::1. The IPv4 attempt is preferred and never completes, so theclient waits out the full 300ms before trying
::1, which then connectsimmediately. Node, whose equivalent knob
(
autoSelectFamilyAttemptTimeout) defaults to 250ms and is user-settable,does the same request in ~15ms. Once per fresh connection.
family hangs rather than refusing -- but that is exactly the case a user
cannot work around from outside the connector.
Related: #1318 ("Happy Eyeballs support", closed 2021) — that report turned
out to be an environment with no IPv6 routes at all, but the thread also
asked how to reach
set_happy_eyeballs_timeoutfrom reqwest, which is stillnot possible today.
Since hyper-util already implements the timeout and its setter, reqwest just
needs to pass it through -- no new connection logic.
Non-goals
The HTTP/3 connector (
src/async_impl/h3_client/connect.rs) has its ownseparate happy-eyeballs implementation by design and is deliberately not
touched here; this option configures the TCP (
HttpConnector) path only.