{
  "id": "go/context-canceled-during-goroutine",
  "signature": "error: context canceled (goroutine worker returned)",
  "signature_zh": "error: context 已取消（goroutine worker 返回）",
  "regex": "error:\\ context\\ canceled\\ \\(goroutine\\ worker\\ returned\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A parent context was canceled (deadline, manual cancel, or HTTP client disconnect) and the worker goroutine observes ctx.Err() == context.Canceled.",
  "root_cause_type": "generic",
  "root_cause_zh": "父 context 被取消（超时、手动 cancel 或 HTTP 客户端断开），worker goroutine 观察到 ctx.Err() == context.Canceled。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The context remains canceled; retries fail immediately and waste resources.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaks the goroutine past shutdown and defeats the purpose of cancellation.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Treat context.Canceled as expected and return without error at shutdown:\n\nif errors.Is(err, context.Canceled) {\n    return nil\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Propagate the context through all calls and check ctx.Err() at loop boundaries.",
      "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-11-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}