# error: context 超时（goroutine worker）

- **ID:** `go/context-deadline-exceeded-worker`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

带截止时间的 ctx 在 worker 完成前过期，通常因为截止时间过短或下游调用过慢。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.19 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Measure p99 latency and set deadline accordingly; propagate ctx everywhere:

ctx, cancel := context.WithTimeout(parent, 5*time.Second)
defer cancel()
   ```
2. **** (85% 成功率)
   ```
   Add retries with exponential backoff for transient downstream timeouts.
   ```

## 无效尝试

- **** — Eliminates the safety net; slow calls can hang the goroutine indefinitely. (80% 失败率)
- **** — Arbitrary; if the downstream is genuinely slow, it still times out and the root latency issue remains. (70% 失败率)
