# error: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

- **ID:** `go/goroutine-leak-http-request`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

An HTTP client call without a context or timeout blocked indefinitely, leaving the goroutine leaked and the request canceled by the client timeout.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
resp, err := http.DefaultClient.Do(req)
   ```
2. **** (90% success)
   ```
   client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Get(url)
   ```

## Dead Ends

- **** — Leaks the goroutine longer; the root cause is missing cancellation. (70% fail)
- **** — http.Get uses DefaultClient with no timeout; can block forever. (90% fail)
