{
  "id": "go/context-canceled-while-sending",
  "signature": "error: context canceled (goroutine blocked on channel send after cancellation)",
  "signature_zh": "error: context canceled（取消后 goroutine 阻塞在 channel 发送上）",
  "regex": "error:\\ context\\ canceled\\ \\(goroutine\\ blocked\\ on\\ channel\\ send\\ after\\ cancellation\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A goroutine keeps sending to a channel after its context is canceled, and the receiver has stopped draining, causing a block or lost work.",
  "root_cause_type": "generic",
  "root_cause_zh": "goroutine 在 context 被取消后仍向 channel 发送数据，而接收方已停止消费，导致阻塞或工作丢失。",
  "versions": [
    {
      "version": "1.7+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Continues to block on a full channel and wastes resources; the cancellation is not honored.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Closing while senders are active panics with send on closed channel.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "select {\ncase ch <- v:\ncase <-ctx.Done():\n    return ctx.Err()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "g, ctx := errgroup.WithContext(ctx)\ng.Go(func() error { return producer(ctx, ch) })\nreturn g.Wait()",
      "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-10-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}