Skip to content

Async::Scheduler#address_resolve returns IPv4 before IPv6 #453

@wtn

Description

@wtn

Async::Scheduler#address_resolve calls Resolv.getaddresses, which breaks the expectation that resolution honors the platform's address-selection policy:

  • Stdlib Ruby: Addrinfo.foreach/Socket.tcp fall through to libc getaddrinfo. On dual-stack hosts where the OS prefers IPv6, AAAA records come back first.
  • Under Async: The scheduler hook routes through Resolv.getaddresses, and Resolv::DNS#each_address iterates IN::A before IN::AAAA, so A records come back first.

On an IPv6-only host (with no IPv4 egress) against a dual-stack endpoint, the IPv4 connect() hangs:

require "async"
require "net/http"

Async do
  p Net::HTTP.get_response(URI "https://dualstack.example.com/").code
end.wait

The request succeeds without Async.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions