# http: response writer timeout: request timed out after 30s

- **ID:** `go/http-response-writer-timeout`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The server's WriteTimeout expired while writing the response body, causing the connection to be closed abruptly.

## Version Compatibility

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

## Workarounds

1. **** (80% success)
   ```
   Set a reasonable WriteTimeout and handle errors from Write: if _, err := w.Write(data); err != nil { return }
   ```
2. **** (75% success)
   ```
   Use http.TimeoutHandler to wrap handlers and return a timeout response: http.TimeoutHandler(handler, 30*time.Second, "timeout")
   ```

## Dead Ends

- **** — May cause slow clients to hold connections indefinitely, leading to resource exhaustion. (70% fail)
- **** — Writes will fail silently; data is corrupted and the connection is already closed. (90% fail)
