{
  "id": "go/grpc-context-deadline-exceeded-stream",
  "signature": "rpc error: code = DeadlineExceeded desc = context deadline exceeded while receiving from stream",
  "signature_zh": "rpc 错误：code = DeadlineExceeded，desc = 从流接收时上下文截止时间已超过",
  "regex": "rpc\\ error:\\ code\\ =\\ DeadlineExceeded\\ desc\\ =\\ context\\ deadline\\ exceeded\\ while\\ receiving\\ from\\ stream",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A server-streaming or bidirectional-streaming RPC exceeded the client context deadline while waiting for the next message.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务端流式或双向流式 RPC 在等待下一条消息时超过了客户端上下文截止时间。",
  "versions": [
    {
      "version": "google.golang.org/grpc 1.52+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Recv returns io.EOF or error; ignoring it loops forever on a dead stream.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Long-lived streams (e.g., subscriptions) should use context.Background() plus server-driven heartbeats, not a fixed deadline.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Loop correctly and check ctx:\nfor {\n  msg, err := stream.Recv()\n  if err == io.EOF { break }\n  if err != nil {\n    if errors.Is(err, context.DeadlineExceeded) { /* re-dial */ }\n    return err\n  }\n  handle(msg)\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "For long-lived streams, use context.Background() and implement server-side heartbeat messages; reconnect on stream error with backoff.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}