Skip to content

Enforce timeout for system DNS resolution - #906

Merged
ryanfowler merged 2 commits into
mainfrom
agent/enforce-system-dns-timeout
Jul 28, 2026
Merged

Enforce timeout for system DNS resolution#906
ryanfowler merged 2 commits into
mainfrom
agent/enforce-system-dns-timeout

Conversation

@ryanfowler

@ryanfowler ryanfowler commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • enforce the supplied TimeoutBudget around the system lookup_host branch of resolve_host_with_doh_tls
  • ensure a stalled system resolver cannot exceed --connect-timeout
  • retain caller-level outer timeouts as defense in depth
  • keep DoH and custom DNS on their existing internal timeout budgets
  • add a boxed, injectable system resolver future for deterministic timeout testing without growing the request future stack

Root cause

The system-resolver branch awaited tokio::net::lookup_host directly, even though resolve_host_with_doh_tls received a timeout budget. Callers such as explicit HTTP/3 setup and QUIC TLS inspection await this resolver directly, allowing a stalled system resolver to run beyond the configured connect timeout.

An initial implementation wrapped the complete resolver state machine in TimeoutBudget::run. That enlarged the stack-resident request future enough to overflow the default-sized fetch-main runtime thread in several network integration tests. The corrected implementation wraps only a boxed system lookup future, leaving the larger DoH/custom resolver paths unchanged.

Impact

System DNS resolution now terminates with the normal request timeout diagnostic when it stalls. Explicit HTTP/3 connections and QUIC TLS inspection honor the configured connect timeout without increasing request stack usage.

Validation

  • cargo fmt --check
  • cargo clippy --locked --all-targets --all-features -- -D warnings
  • cargo test --locked --all-features --lib --bins (872 passed)
  • full CI-equivalent integration suite with --test-threads=2
  • cargo test --locked --all-features --test network -- --test-threads=2 (27 passed)
  • deterministic focused test with a permanently pending injected resolver
  • locally reproduced the prior stack overflow, then verified the failing HTTP/3 cache case passes after the fix

@ryanfowler
ryanfowler marked this pull request as ready for review July 27, 2026 23:29
@ryanfowler
ryanfowler enabled auto-merge July 27, 2026 23:29
@ryanfowler
ryanfowler merged commit c45f8a0 into main Jul 28, 2026
4 checks passed
@ryanfowler
ryanfowler deleted the agent/enforce-system-dns-timeout branch July 28, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant