{"record":{"id":"527e6fdcbf64db2c","repo":"Hmbown/CodeWhale","slug":"sse-stream-request-failed-after-http-1-1-fallback","errorCode":null,"errorMessage":"SSE stream request failed after HTTP/1.1 fallback: {err}. `codewhale doctor` can still pass when non-streaming requests work; on Windows or proxy networks, try `CODEWHALE_FORCE_HTTP1=1` and rerun `codewhale`.","messagePattern":"SSE stream request failed after HTTP/1\\.1 fallback: (.+?)\\. `codewhale doctor` can still pass when non-streaming requests work; on Windows or proxy networks, try `CODEWHALE_FORCE_HTTP1=1` and rerun `codewhale`\\.","errorType":"exception","errorClass":"LlmError::NetworkError","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/stream_entry.rs","lineNumber":144,"sourceCode":"            || reqwest_error.is_timeout()\n            || reqwest_error.is_request();\n    }\n\n    should_retry_with_h1(policy, &format!(\"{err:#}\"))\n}\n\n/// Preserve provider-semantic failures returned by the H1 attempt. Only a\n/// transport failure should be normalized into the shared retryable network\n/// error; otherwise an auth or invalid-request failure could be retried as if\n/// switching protocols had failed.\nfn h1_fallback_error(err: anyhow::Error) -> anyhow::Error {\n    if let Some(llm_error) = err.downcast_ref::<LlmError>()\n        && !matches!(llm_error, LlmError::NetworkError(_) | LlmError::Timeout(_))\n    {\n        return err;\n    }\n\n    anyhow::Error::new(LlmError::NetworkError(format!(\n        \"SSE stream request failed after HTTP/1.1 fallback: {err}. \\\n         `codewhale doctor` can still pass when non-streaming requests work; \\\n         on Windows or proxy networks, try `CODEWHALE_FORCE_HTTP1=1` and rerun `codewhale`.\"\n    )))\n}\n\n/// Open an SSE response through the shared transport policy.\n///\n/// `attempt` builds and sends one wire-specific request on the client\n/// selected for the given policy (via [`client_for_policy`]); everything\n/// transport-shared lives here:\n///\n/// - the response-header wait is bounded by `open_req.open_timeout`;\n/// - a classified transport failure or header stall on the dual client\n///   retries exactly once on the HTTP/1.1 twin;\n/// - a failure on an already H1-pinned request never retries;\n/// - once response headers have been received the seam never retries —\n///   body/stream errors belong to the adapter's decode loop.","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client/stream_entry.rs#L126-L162","documentation":"After the initial (default HTTP/2-capable) SSE request fails and the client retries over HTTP/1.1, this wraps the residual network or timeout error into an `LlmError::NetworkError` with guidance. It marks that streaming is broken even with the H1 fallback, while hinting that `codewhale doctor` may still pass because non-streaming requests succeed.","triggerScenarios":"`open_sse_response` -> `h1_fallback_error(err)` fires when the HTTP/1.1 retry of the SSE open returns `LlmError::NetworkError` or `LlmError::Timeout` (other LlmError kinds are returned untouched).","commonSituations":"Corporate proxies or middleboxes that break streaming responses; Windows TLS/socket stack issues; providers blocking long-lived connections; `CODEWHALE_FORCE_HTTP1=1` still not fixing an underlying firewall drop.","solutions":["Run `codewhale doctor` to confirm non-streaming connectivity works and isolate the problem to streaming.","Set `CODEWHALE_FORCE_HTTP1=1` and rerun if you have not already; if this error persists with H1 pinned, the cause is not HTTP version negotiation.","Check proxy/VPN/firewall settings for interference with long-lived (streaming) connections; try disabling the proxy or allowing the provider host.","Retry after network changes; if the error is a Timeout, increase check of DNS/latency and provider status page."],"exampleFix":"# before\n$ codewhale\nSSE stream request failed after HTTP/1.1 fallback: ...\n# after\n$ CODEWHALE_FORCE_HTTP1=1 codewhale   # or fix proxy allowlist for streaming","handlingStrategy":"retry","validationCode":"// pre-check streaming reachability\nlet ok = std::process::Command::new(\"curl\")\n    .args([\"-sS\", \"-N\", \"--max-time\", \"10\", \"-H\", \"Accept: text/event-stream\", &base_url])\n    .status().map(|s| s.success()).unwrap_or(false);","typeGuard":"fn is_stream_transport_failure(err: &anyhow::Error) -> bool {\n    err.downcast_ref::<LlmError>().map_or(false, |e|\n        matches!(e, LlmError::NetworkError(_) | LlmError::Timeout(_)))\n}","tryCatchPattern":"match open_sse_response(req).await {\n    Err(e) if is_stream_transport_failure(&e) => {\n        // fallback: retry with backoff, then surface `codewhale doctor` hint\n        if let Err(e2) = open_sse_response(req).await {\n            eprintln!(\"Streaming failed twice: {e2}. Run `codewhale doctor`.\");\n        }\n    }\n    other => other?,\n}","preventionTips":["Keep proxy/VPN allowlists current for the provider's streaming endpoints.","Prefer wired/stable networks when streaming; mobile and captive portals stall SSE.","Set CODEWHALE_FORCE_HTTP1 only as a deliberate workaround and revisit it periodically.","Run `codewhale doctor` after network environment changes."],"tags":["network","sse","streaming","http1"],"backgroundTag":"network-request-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}