Repository navigation
Opt-in for RFC 6724-compliant host resolution - #482
Open
GoodForOneFare wants to merge 1 commit into
Open
GoodForOneFare wants to merge 1 commit into
GoodForOneFare wants to merge 1 commit into
Conversation
Under a fiber scheduler, Ruby hands every hostname lookup to `address_resolve`, which answered with pure-Ruby `Resolv`. That only reads `/etc/hosts` and `/etc/resolv.conf`, so the same code resolves differently inside and outside `Async`: macOS `/etc/resolver`, mDNS and `nsswitch.conf` are ignored, and RFC 6724 / `gai.conf` ordering is lost, so IPv4 addresses always come before IPv6 (see socketry#453, socketry#357, socketry#180). Keep `Resolv` as the default, but resolve with `getaddrinfo` on a short-lived thread when `ASYNC_SCHEDULER_PLATFORM_RESOLVER=true` or `Scheduler.new(platform_resolver: true)`. At most 16 callers (or the limit given to `platform_resolver:`) wait on lookups at once per scheduler. `getaddrinfo` can't be cancelled, so a caller that is stopped or times out frees its slot immediately while the abandoned lookup runs until the system resolver gives up, as it would outside the scheduler.
GoodForOneFare
force-pushed
the
gordo-async-dns
branch
from
November 4, 2026 19:20
be7da44 to
2116add
Compare
GoodForOneFare
marked this pull request as ready for review
November 4, 2026 19:30
This branch has not been deployed
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.
Under a fiber scheduler, Ruby hands every hostname lookup to
Scheduler#address_resolve, which answers with pure-RubyResolv.Resolvonly reads/etc/hostsand/etc/resolv.conf, so the same code resolves differently inside and outsideAsync:/etc/resolver, mDNS andnsswitch.confare ignored.gai.confordering is lost, so IPv4 addresses always come before IPv6 (Async::Scheduler#address_resolvereturns IPv4 before IPv6 #453).See also #357 and #180.
This keeps
Resolvas the default and adds an opt-in that resolves withgetaddrinfoon a short-lived thread, without blocking the event loop:ASYNC_SCHEDULER_PLATFORM_RESOLVER=true, orScheduler.new(platform_resolver: true), or an integer such asplatform_resolver: 4to set the limit.At most 16 callers (by default) wait on lookups at once per scheduler; further callers wait for a free slot.
getaddrinfocan't be cancelled, so a caller that is stopped or times out frees its slot immediately, and the abandoned lookup runs until the system resolver gives up, the same as it would outside the scheduler.Unlike #454, which reorders
Resolvresults, this delegates to the system resolver, so lookups honour the same configuration inside and outsideAsync.Types of Changes
Contribution