{
  "id": "go/goroutine-context-cancel-not-propagated",
  "signature": "fatal error: all goroutines are asleep - deadlock! (context cancellation not propagated)",
  "signature_zh": "致命错误：所有协程都在休眠 - 死锁！（上下文取消未传播）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(context\\ cancellation\\ not\\ propagated\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A parent goroutine cancels a context but child goroutines are not listening to the context's Done channel, causing them to block indefinitely.",
  "root_cause_type": "generic",
  "root_cause_zh": "父协程取消上下文，但子协程未监听上下文的 Done 通道，导致它们无限阻塞。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Only checking context.Err() without using select on Done.",
      "why_fails": "context.Err() is only set after cancellation; without select, goroutine may not wake up.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Passing context by value but not using it in select.",
      "why_fails": "The context is available but not used to unblock the goroutine.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use select to listen on context.Done() in blocking operations.",
      "success_rate": 0.95,
      "how": "select {\ncase result := <-ch:\n    return result\ncase <-ctx.Done():\n    return ctx.Err()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Pass context to functions and check cancellation periodically.",
      "success_rate": 0.9,
      "how": "func worker(ctx context.Context) error {\n    for {\n        select {\n        case <-ctx.Done():\n            return ctx.Err()\n        default:\n            // do work\n        }\n    }\n}",
      "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": "2025-02-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}