{
  "id": "go/too-many-open-files-goroutine-leak",
  "signature": "error: accept tcp :8080: accept4: too many open files",
  "signature_zh": "错误：accept tcp :8080: accept4: 打开的文件过多",
  "regex": "error:\\ accept\\ tcp\\ :8080:\\ accept4:\\ too\\ many\\ open\\ files",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Goroutines leak because HTTP response bodies are not closed or client connections are not drained, exhausting file descriptors.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于未关闭 HTTP 响应体或未排空客户端连接，goroutine 泄漏，最终耗尽文件描述符。",
  "versions": [
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Delays the crash; leaked descriptors keep accumulating and the process eventually dies again.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Treats the symptom; the leak persists and restart frequency increases.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "resp, err := http.Get(url)\nif err != nil { return err }\ndefer resp.Body.Close()\nio.Copy(io.Discard, resp.Body)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ctx, cancel := context.WithTimeout(ctx, 5*time.Second)\ndefer cancel()\nreq, _ := http.NewRequestWithContext(ctx, \"GET\", url, nil)\nresp, err := http.DefaultClient.Do(req)",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-24",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}