{
  "id": "go/grpc-canceled-by-client",
  "signature": "rpc error: code = Canceled desc = context canceled",
  "signature_zh": "rpc 错误：code = Canceled，desc = 上下文已取消",
  "regex": "rpc\\ error:\\ code\\ =\\ Canceled\\ desc\\ =\\ context\\ canceled",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The client canceled the RPC (via context cancel, HTTP/2 RST_STREAM, or parent context timeout) before the server finished.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端在服务端完成前取消了 RPC（通过 context cancel、HTTP/2 RST_STREAM 或父上下文超时）。",
  "versions": [
    {
      "version": "google.golang.org/grpc 1.48+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the caller intentionally canceled (e.g., user closed the page), retrying wastes resources.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Canceled is a normal client behavior; alerting creates noise.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Check ctx.Err() in the server handler and exit early:\nselect {\ncase <-ctx.Done():\n    return nil, status.FromContextError(ctx.Err()).Err()\ndefault:\n}\n// continue processing",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Distinguish client cancel from server-side timeout by inspecting the parent context; treat codes.Canceled as INFO in logs and metrics.",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}