{
  "id": "go/grpc-stream-already-closed",
  "signature": "rpc error: code = Internal desc = grpc: failed to send message: stream is already closed",
  "signature_zh": "rpc 错误：code = Internal desc = grpc: 发送消息失败：流已关闭",
  "regex": "rpc\\ error:\\ code\\ =\\ Internal\\ desc\\ =\\ grpc:\\ failed\\ to\\ send\\ message:\\ stream\\ is\\ already\\ closed",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling Send on a client or server stream after CloseSend or after the stream returned io.EOF. Often caused by concurrent Send from multiple goroutines.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 CloseSend 之后或流返回 io.EOF 之后调用流的 Send。常由多个 goroutine 并发调用 Send 引起。",
  "versions": [
    {
      "version": "1.50+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "gRPC streams are one-shot; CloseSend is idempotent but does not reopen the stream for sending.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Subsequent Sends return the same error; the messages are silently dropped.",
      "fail_rate": 0.88,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "for _, m := range msgs {\n    if err := stream.Send(m); err != nil {\n        if err == io.EOF { break }\n        return err\n    }\n}\nreturn stream.CloseSend()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "for {\n    stream, err := client.Push(ctx)\n    if err != nil { return err }\n    if err := sendAll(stream, batch); err != nil { return err }\n    if _, err := stream.CloseAndRecv(); err != nil { return err }\n    if done(batch) { return nil }\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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}