{
  "id": "go/grpc-stream-send-on-closed",
  "signature": "rpc error: code = Internal desc = grpc: failed to send message on stream: stream closed",
  "signature_zh": "rpc 错误：代码 = Internal 描述 = grpc: 在流上发送消息失败：流已关闭",
  "regex": "rpc\\ error:\\ code\\ =\\ Internal\\ desc\\ =\\ grpc:\\ failed\\ to\\ send\\ message\\ on\\ stream:\\ stream\\ closed",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The client or server called Send on a stream after it was closed (CloseSend called, server returned, or context canceled). Writes to a terminal stream are rejected.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端或服务端在流关闭后（已调用 CloseSend、服务端已返回，或上下文取消）调用了 Send。对已终止流的写入会被拒绝。",
  "versions": [
    {
      "version": "google.golang.org/grpc v1.42+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "A closed stream cannot be reopened; the same stream handle remains terminal.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Closure is a state, not a timing race; sleeping does not reopen the stream.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.8,
      "how": "stream, err := client.Upload(ctx)\nif err != nil { return err }\nfor _, m := range msgs {\n    if err := stream.Send(m); err != nil {\n        stream, err = client.Upload(ctx) // reopen\n        if err != nil { return err }\n    }\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "defer stream.CloseSend()\n// ensure all Send calls complete before CloseSend runs",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}