Skip to content

Ctrl+C counts in-flight lookups as resolver failures and can raise a false "rate-limiting" abort with exit 1 #42

Closed

Description

@TMHSDigital

Why it matters

When a scan is cancelled (Ctrl+C, SIGTERM, or the reliability guard's own cancel()), every lookup still in flight returns context.Canceled. That error is classified as OutcomeOther and counted as an infrastructure failure:

  • The final summary shows up to -t (default 100) phantom other failures after every interrupt.
  • Once at least 200 jobs have been processed, those phantom failures can push the failure rate over 20%. The guard then prints aborting scan: NN% of N queries failed ... likely resolver rate-limiting, which blames the resolver for something the user did. run() sees EventError and exits 1, so a clean user interrupt looks like a resolver outage to any calling script.
  • After a genuine reliability abort, the cancelled in-flight jobs further inflate the reported failure counts.

Evidence

I verified Go's behaviour with a standalone probe that cancels a LookupIP against an unreachable resolver:

err=lookup www.example.com: operation was canceled
IsTimeout=false IsNotFound=false Err="operation was canceled" canceled=true
  • internal/dns/resolver.go:41-58: Classify falls through to OutcomeOther for that error.
  • internal/dns/resolver.go:173-176: ctx.Err() is checked only before each attempt, not after the lookup returns.
  • internal/scan/runner.go:448-474: processJob calls st.add(outcome) and checkReliability without checking whether ctx was cancelled.
  • main.go:354-356,379-381: any EventError causes exit 1.

Suggested approach

  • In Classify (or ResolveDomainWithRetry), map errors.Is(err, context.Canceled) to a new OutcomeCanceled that is never counted toward failures() or the summary.
  • In processJob, drop the job from the counters (or count it as cancelled) when ctx.Err() != nil after resolution, and skip checkReliability.
  • Optionally exit 130 on SIGINT (the shell convention) so scripts can tell an interrupt apart from success and from failure.

Done when

  • Interrupting a scan mid-run never increments other, timeout or refused, and never emits the rate-limiting abort message. A runner_test.go case cancels with blocking in-flight hooks to prove it.
  • The exit code for an interrupt is defined and documented.

Activity

  1. added
    bug
    priority: medium
    area: dns
    area: cli
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: dnsbugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions