resolver: a query cut short by the caller's context records no reason (closes #298)
check / check (push) Canceled after 0s

When the caller's context ends, the next query returns
ErrContextCanceled before anything is sent. querySingleType recorded
that as a network error, which outranks a timeout, so a nameserver that
had only timed out could be reported as "network error: context
canceled". It now records no reason for it.

Model: opus-5-5
This commit is contained in:
2026-10-15 16:38:24 +00:00
parent 06ae357165
commit 5f20fa31c8
3 changed files with 39 additions and 0 deletions
+4
View File
@@ -863,6 +863,10 @@ func (r *Resolver) querySingleType(
if err != nil {
err = fmt.Errorf("query %s @%s: %w", hostname, nsIP, err)
}
case errors.Is(err, ErrContextCanceled):
// The caller's context ended and cut the query short. That
// says nothing about the nameserver, so no reason is
// recorded.
case isTimeout(err):
state.gotTimeout = true
case errors.Is(err, ErrRefused):