{
  "id": "dotnet/blazor-wasm-prerendering-timeout",
  "signature": "System.Threading.Tasks.TaskCanceledException: A task was canceled. at Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost..ctor",
  "signature_zh": "System.Threading.Tasks.TaskCanceledException: 任务已取消。在Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost..ctor处",
  "regex": "System\\.Threading\\.Tasks\\.TaskCanceledException.*A task was canceled.*CircuitHost",
  "domain": "dotnet",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Blazor Server or WASM prerendering times out because the component's OnInitializedAsync method performs a long-running operation (e.g., database call or HTTP request) that exceeds the 30-second default timeout.",
  "root_cause_type": "generic",
  "root_cause_zh": "Blazor Server或WASM预渲染超时，因为组件的OnInitializedAsync方法执行了超过30秒默认超时的长时间运行操作（例如数据库调用或HTTP请求）。",
  "versions": [
    {
      "version": ".NET 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Blazor Server 6.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Blazor WASM 6.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing the Kestrel request timeout globally in appsettings.json",
      "why_fails": "The timeout is specific to Blazor circuit creation, not the HTTP request pipeline, so Kestrel settings have no effect.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding a try-catch around the entire OnInitializedAsync method to swallow the exception",
      "why_fails": "The circuit creation is already canceled before the catch block executes, so the component fails to render.",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Configure the Blazor circuit timeout by setting 'CircuitOptions.DisconnectedCircuitRetentionPeriod' and 'CircuitOptions.JSInteropDefaultCallTimeout' in Program.cs to a higher value (e.g., 60 seconds).",
      "success_rate": 0.8,
      "how": "Configure the Blazor circuit timeout by setting 'CircuitOptions.DisconnectedCircuitRetentionPeriod' and 'CircuitOptions.JSInteropDefaultCallTimeout' in Program.cs to a higher value (e.g., 60 seconds).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Move long-running operations out of OnInitializedAsync and use OnAfterRenderAsync with a loading state to fetch data after the circuit is established.",
      "success_rate": 0.9,
      "how": "Move long-running operations out of OnInitializedAsync and use OnAfterRenderAsync with a loading state to fetch data after the circuit is established.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Configure the Blazor circuit timeout by setting 'CircuitOptions.DisconnectedCircuitRetentionPeriod' and 'CircuitOptions.JSInteropDefaultCallTimeout' in Program.cs to a higher value (e.g., 60 seconds).",
    "Move long-running operations out of OnInitializedAsync and use OnAfterRenderAsync with a loading state to fetch data after the circuit is established."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerendering?view=aspnetcore-8.0",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}