{
  "id": "go/http-server-timeout-write-broken-pipe",
  "signature": "error: http: superfluous response.WriteHeader call from ... (net/http: write tcp ...: write: broken pipe)",
  "signature_zh": "错误：多余的Response.WriteHeader调用（net/http：写入TCP...：写入：管道断裂）",
  "regex": "error:\\ http:\\ superfluous\\ response\\.WriteHeader\\ call\\ from\\ \\.\\.\\.\\ \\(net/http:\\ write\\ tcp\\ \\.\\.\\.:\\ write:\\ broken\\ pipe\\)",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "HTTP处理程序在已经写入响应体后又调用了WriteHeader，且客户端提前断开连接，导致写入操作返回broken pipe错误。",
  "root_cause_type": "generic",
  "root_cause_zh": "HTTP处理程序在写入响应体后再次调用WriteHeader，同时客户端连接已断开，导致底层TCP写入返回管道断裂错误。",
  "versions": [
    {
      "version": "1.20",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "忽略错误不会解决根本问题，客户端已断开，继续写入只会浪费资源并可能引发更多错误。",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "net/http没有提供直接检查写入状态的方法，容易引入竞态条件。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "if w.Written() { return } // 使用自定义ResponseWriter跟踪写入状态，避免重复调用WriteHeader",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在写入响应体前确保所有Header设置完成，并在WriteHeader后不再修改Header。",
      "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-03-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}