{
  "id": "go/goroutine-context-cancel-not-checked",
  "signature": "fatal error: all goroutines are asleep - deadlock! (context canceled)",
  "signature_zh": "致命错误：所有协程都处于睡眠状态 - 死锁！（上下文已取消）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(context\\ canceled\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Goroutines block on channel operations after context is canceled, without checking cancellation.",
  "root_cause_type": "generic",
  "root_cause_zh": "协程在上下文被取消后阻塞在通道操作上，没有检查取消状态。",
  "versions": [
    {
      "version": "1.7",
      "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": "Ignoring context in select",
      "why_fails": "Context cancellation doesn't automatically unblock other channels.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using time.Sleep to wait for cancellation",
      "why_fails": "Sleep doesn't handle cancellation; goroutine still blocks.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always include ctx.Done() in select",
      "success_rate": 0.95,
      "how": "select {\ncase <-ch:\ncase <-ctx.Done():\n    return ctx.Err()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use context.WithTimeout to automatically cancel",
      "success_rate": 0.9,
      "how": "ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\nselect {\ncase <-ch:\ncase <-ctx.Done():\n    // timeout\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": "2026-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}