{
  "id": "go/net-http-request-canceled-by-client",
  "signature": "error: net/http: request canceled (Client.Timeout or context cancellation)",
  "signature_zh": "错误：net/http：请求被取消（客户端超时或上下文取消）",
  "regex": "error:\\ net/http:\\ request\\ canceled\\ \\(Client\\.Timeout\\ or\\ context\\ cancellation\\)",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The client canceled the HTTP request due to timeout or explicit context cancellation before the server responded.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端因超时或显式上下文取消，在服务器响应前取消了HTTP请求。",
  "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": "Increasing client timeout indefinitely without handling context",
      "why_fails": "Context cancellation can still occur from upstream, leading to same error; indefinite timeout is not scalable.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the error and retrying blindly",
      "why_fails": "Retrying without checking context may amplify load and cause cascading failures.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a custom context with proper timeout and cancellation handling",
      "success_rate": 0.9,
      "how": "ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\nreq, _ := http.NewRequestWithContext(ctx, \"GET\", url, nil)\nresp, err := client.Do(req)\nif errors.Is(err, context.Canceled) { /* handle gracefully */ }",
      "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-01-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}