{
  "id": "python/fastapi-websocket-disconnect-loop",
  "signature": "starlette.websockets.WebSocketDisconnect: 1006",
  "signature_zh": "starlette.websockets.WebSocketDisconnect: 1006",
  "regex": "starlette\\.websockets\\.WebSocketDisconnect:\\ 1006",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "Client closed the socket without a close frame; server loop keeps calling receive/send without catching WebSocketDisconnect.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端未发送关闭帧即关闭套接字；服务端循环继续调用 receive/send 而未捕获 WebSocketDisconnect。",
  "versions": [
    {
      "version": "0.100+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.110+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides real errors and leaks sockets; CPU spins on reconnect storms.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "close() on a dead socket raises again.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "try:\n    while True:\n        msg = await ws.receive_text()\n        await ws.send_text(msg)\nexcept WebSocketDisconnect:\n    pass",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use ws.iter_text() and break on disconnect; send a ping interval for liveness.",
      "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-09-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}