apple / apple/swift-async-dns-resolver

DNSSD based queries are incomplete

Open
#38 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Swift
Stars
160
Forks
33
PR merge metrics
No merged PRs in 30d

Description

On macOS (where DNSSD is being used by default), queries for domains with multiple records, such as:

```
AsyncDNSResolver().queryAAAA(name: "iadsdk.apple.com.akadns.net")
```

normally return the two `AAAA` records associated with the domain. However, occasionally, only one is returned. It happens at roughly 1% of the time in my tests, but since this is a race, that number will fluctuate with the different timing conditions.

The core reason for this is that the library calls [`DNSServiceProcessResult`](https://github.com/apple/swift-async-dns-resolver/blob/08c07ff31a745ee5e522ac10132fb4949834d925/Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift#L162) precisely once. The callbacks are delivered as a result of this call, but DNSSD offers no guarantees about how many records will get provided per `DNSServiceProcessResult` invocation.

Additionally, while DNSSD provides [`kDNSServiceFlagsMoreComing`](https://developer.apple.com/documentation/dnssd/1823436-anonymous/kdnsserviceflagsmorecoming), the flag is designed to reduce unnecessary UI updates only. It'd be fragile to use attach additional semantics to it.

Contributor guide

Open the contributing guide

Research direction

Start in Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift around the DNSServiceProcessResult call at line 162. Reproduce the queryAAAA example for iadsdk.apple.com.akadns.net on macOS and inspect how callbacks are consumed across result processing. Done means queries with multiple records consistently return all associated records without relying on kDNSServiceFlagsMoreComing.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.