Repository navigation
feat(resolution): resolve destinations off the actor, under one deadline - #197
Merged
Merged
Conversation
Forward resolution of trace, traceClassified, traceStream, ping, the TCP and UDP probes and multipath flows now runs in an executor slot through one primitive, awaitBlockingLookup, which STUN server-name lookups share. The caller's wait ends at an absolute deadline on DiscoveryClock (20 s for traces and ping, config.timeout from entry for the probes); cancellation, by the task or the trace handle, releases the caller at once, and a trace checks its handle at the handoff to probing. One inline classifier answers forced-family literals, mismatches, NULs, IPv4 loopback and unscoped non-link-local IPv6 literals without a resolver or seam; other literals use a one-slot Literal Lane so stalled name lookups cannot hold back a numeric destination. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
Changelog bullet and upgrade-guide entry for each changed caller-visible behaviour, finding 5 marked fixed with its tests, the API reference's PreferredFamily notes, and a ROADMAP line for an absolute cutoff in the TCP and UDP probe operations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
…off-actor # Conflicts: # docs/README.md
On CI more than half a second passed between entry and the handoff, so the budget test's probe found nothing left. It now leaves 5 s, still well inside the 20 s watchdog that a probe given its whole 60 s timeout exceeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
The system resolver treats "127.1" as numeric, but inet_pton does not, so it was queued with names and waited out the budget when the name slots were stalled. Lane selection now also accepts what inet_aton recognizes; resolution itself is unchanged. The full-executor test pings 127.1; without the change it is still running at the 20 s watchdog. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
inet_aton stops at whitespace and accepts what came before it, so "127.1 example.com" would have been sent to the lane reserved for numeric destinations. Lane selection now requires every character to be one a numeric IPv4 form can contain before asking inet_aton. numericDestinations fails for the three whitespace cases without the check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
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.
Summary
Turning a destination name into an address (
getaddrinfo) can stall for tens of seconds when DNS is broken, which is the normal condition for software that diagnoses networks. Until now SwiftFTR made that call on the tracer actor (traces) or on a Swift concurrency thread (ping and the TCP and UDP probes). A stalled lookup therefore froze every other call on the tracer,cancelActiveTraces()andnetworkChanged()included, could not be cancelled, and had no time limit (finding 5 in docs/ROBUSTNESS-TESTING.md, #84).This PR moves the call onto the library's blocking-I/O executor, through one small primitive that STUN server-name lookups now share. The wait ends at a deadline, and cancellation releases the caller at once. The address that gets probed does not change. Numeric destinations never queue behind stalled name lookups: either they are answered without a lookup, or they use a one-slot executor of their own (the "Literal Lane"). A ping to
1.1.1.1while DNS is broken is this library's core diagnostic case.This is PR 1 of the Resolution Off The Actor slice (docs/BLOCKING-IO.md). PR 2 adds decision 7's configurable budget and makes
discoverPathsresolve once.Invariants
Off the actor.
getaddrinfo, and the test seam standing in for it, runs only in aBlockingIOExecutorslot, never on aSwiftFTRactor or a cooperative-pool thread. The seam replaces only that blocking branch.One deadline. The caller's wait for resolution ends by an absolute deadline on
DiscoveryClock. Nothing is submitted once it has passed. An outcome, value or error, that reaches the waiting side after the deadline is a timeout. When several apply, cancellation wins over expiry, and expiry over the lookup's own outcome. Not promised: a lookup may be enqueued in the instant before expiry; it is then withdrawn, or skipped by the worker's own check.Release. Cancellation by the task or the trace handle, observed during resolution, releases the caller at once with the right error. Each operation checks its task and handle once at the handoff to probing, before it creates a socket.
Same answer. A resolution accepted before its deadline gives what
getaddrinfo(or the forced-family parse) gives today. One inline classifier answers, with no seam and no submission:.autoIPv4 loopback literals, which Libinfo never synthesizes for;.autounscoped IPv6 literals outside fe80::/10, fec0::/10 and ff00::/8.A test checks byte for byte that these match
getaddrinfo. Scoped and embedded-scope forms still go to the resolver.Caller-visible changes
resolutionFailed(details: "timed out"). Before, it waited for as long asgetaddrinfotook.tcpProbeandudpProbewait for resolution at mosttimeoutfrom entry and give the probe what is left. If resolution uses it all, they return their existing resolution failure with no socket set up.cancelActiveTraces()andnetworkChanged(). Before, the tracer's calls waited behind the lookup, and a trace cancelled during it still made its socket and sent its probe burst.CancellationErroreven when the lookup then fails. Before, it threwresolutionFailed.Reproduce
The tests in
ResolutionOffActorTestsfail onmain, except the stream case cancelled by its own consumer, whose behaviour does not change. Run onmain, the stall tests hit their 20 s watchdog, and the pool test waits out its 60 s gate.🤖 Generated with Claude Code
https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X