Skip to content

Conversation

maradini77
Copy link

Summary

Adds a safe default timeout to the HTTP RPC client to avoid requests hanging indefinitely when no context deadline is provided.

Changes

  • rpc/http.go:
    • DialHTTP now uses &http.Client{Timeout: 30 * time.Second}.
    • When no custom client is provided, newClientTransportHTTP initializes http.Client with Timeout: 30 * time.Second.

Rationale

  • Using http.Client without a timeout is a known anti-pattern and can lead to resource exhaustion/DoS if servers keep connections open without responding.

Backward Compatibility

  • Custom clients provided via WithHTTPClient or DialHTTPWithClient are respected and unchanged.

@maradini77 maradini77 requested a review from fjl as a code owner September 9, 2025 13:43
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