{
  "id": "go/grpc-stream-interrupted-client-cancel",
  "signature": "rpc error: code = Canceled desc = grpc: the client connection is closing",
  "signature_zh": "rpc错误：代码=已取消 描述=grpc：客户端连接正在关闭",
  "regex": "rpc\\ error:\\ code\\ =\\ Canceled\\ desc\\ =\\ grpc:\\ the\\ client\\ connection\\ is\\ closing",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The gRPC client cancelled the context, causing the streaming RPC to terminate prematurely.",
  "root_cause_type": "generic",
  "root_cause_zh": "gRPC客户端取消了上下文，导致流式RPC过早终止。",
  "versions": [
    {
      "version": "1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Ignore the cancellation and retry the same stream.",
      "why_fails": "Stream is closed; must create a new stream.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase context timeout to avoid cancellation.",
      "why_fails": "Cancellation may be intentional (e.g., user abort).",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Handle context cancellation gracefully and restart stream.",
      "success_rate": 0.9,
      "how": "for {\n    stream, err := client.StreamRPC(ctx)\n    if err != nil { return }\n    for {\n        msg, err := stream.Recv()\n        if errors.Is(err, context.Canceled) { break }\n    }\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a separate context for stream to avoid parent cancellation.",
      "success_rate": 0.85,
      "how": "streamCtx, cancel := context.WithCancel(context.Background())\ndefer cancel()\nstream, _ := client.StreamRPC(streamCtx)",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}