{
  "id": "go/http-server-shutdown-error",
  "signature": "http: Server.Shutdown: context deadline exceeded",
  "signature_zh": "http: 服务器关闭：上下文截止时间已超过",
  "regex": "http:\\ Server\\.Shutdown:\\ context\\ deadline\\ exceeded",
  "domain": "go",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "During graceful shutdown, the server did not finish processing active requests within the given context deadline.",
  "root_cause_type": "generic",
  "root_cause_zh": "在优雅关闭期间，服务器未能在给定的上下文截止时间内完成处理活动请求。",
  "versions": [
    {
      "version": "1.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Delays shutdown indefinitely and may not solve if requests hang forever.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses active connections and may corrupt data.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Set a reasonable timeout and handle error: ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second); defer cancel(); if err := srv.Shutdown(ctx); err != nil { log.Fatal(err) }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Track active connections and wait for them before calling Shutdown: use sync.WaitGroup to wait for handlers to finish.",
      "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-02-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}