{
  "id": "go/grpc-server-stream-closed",
  "signature": "rpc error: code = Internal desc = grpc: the server has been stopped",
  "signature_zh": "rpc 错误：code = Internal，desc = grpc：服务器已停止",
  "regex": "rpc\\ error:\\ code\\ =\\ Internal\\ desc\\ =\\ grpc:\\ the\\ server\\ has\\ been\\ stopped",
  "domain": "go",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "A handler attempted to send on a stream after grpc.Server.Stop() or GracefulStop() was called. Common during shutdown when in-flight handlers are not drained.",
  "root_cause_type": "generic",
  "root_cause_zh": "在调用 grpc.Server.Stop() 或 GracefulStop() 后，处理器仍尝试在流上发送。常见于关闭期间未排空进行中的处理器。",
  "versions": [
    {
      "version": "google.golang.org/grpc 1.40+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Restarting does not drain in-flight handlers; the error recurs on the next shutdown.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Clients receive truncated responses and may retry with stale state.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use GracefulStop with a timeout fallback:\ndone := make(chan struct{})\ngo func() {\n    grpcServer.GracefulStop()\n    close(done)\n}()\nselect {\ncase <-done:\ncase <-time.After(30 * time.Second):\n    grpcServer.Stop()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Check ctx.Err() before each Send in streaming handlers:\nif err := stream.Context().Err(); err != nil {\n    return status.FromContextError(err).Err()\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": "2024-03-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}