{"record":{"id":"5e9f66f29ab0faef","repo":"Hmbown/CodeWhale","slug":"sse-stream-request-did-not-receive-response-header","errorCode":null,"errorMessage":"SSE stream request did not receive response headers after {}s. `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 did not receive response headers after (.+?)s\\. `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":186,"sourceCode":"    F: Fn(StreamHttpPolicy) -> Fut,\n    Fut: Future<Output = Result<reqwest::Response>>,\n{\n    let fallback_reason = match tokio::time::timeout(\n        open_req.open_timeout,\n        attempt(open_req.policy),\n    )\n    .await\n    {\n        Ok(Ok(response)) => return Ok(response),\n        Ok(Err(err)) => {\n            if !should_retry_error_with_h1(open_req.policy, &err) {\n                return Err(err);\n            }\n            \"transport error before response headers\"\n        }\n        Err(_elapsed) => {\n            if open_req.policy == StreamHttpPolicy::Http1Only {\n                return Err(anyhow::Error::new(LlmError::NetworkError(format!(\n                    \"SSE stream request did not receive response headers after {}s. \\\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                    open_req.open_timeout.as_secs()\n                ))));\n            }\n            \"response-header timeout\"\n        }\n    };\n\n    // No response body exists yet, so switching protocols and replaying the\n    // request is safe. The policy guard above keeps this to exactly one retry.\n    let h1_req = open_req.clone().with_h1_only();\n    crate::logging::warn(format!(\n        \"SSE stream {fallback_reason}; retrying once with HTTP/1.1\"\n    ));\n    match tokio::time::timeout(h1_req.open_timeout, attempt(h1_req.policy)).await {\n        Ok(Ok(response)) => Ok(response),","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client/stream_entry.rs#L168-L204","documentation":"`open_sse_response` bounds how long the SSE open may take to produce response headers. When the deadline elapses and the policy is pinned to HTTP/1.1 only (so there is no HTTP/2 fallback to try), it returns this `LlmError::NetworkError` timeout — deliberately typed so the shared retry layer recognizes it as retryable.","triggerScenarios":"Calling the SSE open path with `StreamHttpPolicy::Http1Only` (e.g. `CODEWHALE_FORCE_HTTP1=1` set) and the server/proxy never returns response headers within `open_req.open_timeout` seconds.","commonSituations":"Users who pinned HTTP/1.1 to work around an HTTP/2 issue then hit a stalled proxy; firewalls that black-hole the connection so headers never arrive; overloaded provider endpoints.","solutions":["Verify network reachability to the provider host (curl the base URL) — a total header stall is usually proxy/firewall, not codewhale.","If HTTP/1.1 was pinned unnecessarily, unset `CODEWHALE_FORCE_HTTP1=1` so the dual-protocol path is available.","Retry — this error is retryable by the shared retry layer and transient stalls often clear.","Check provider status/incident pages if the stall persists across endpoints."],"exampleFix":"# before (H1 pinned, headers stall)\n$ CODEWHALE_FORCE_HTTP1=1 codewhale\nSSE stream request did not receive response headers after 30s ...\n# after\n$ unset CODEWHALE_FORCE_HTTP1 && codewhale","handlingStrategy":"retry","validationCode":"// quick header-stall probe before opening the stream\ntcp_ping_or_curl_head(&host, Duration::from_secs(5))?; // fail fast if host unreachable","typeGuard":"fn is_header_stall_timeout(err: &anyhow::Error) -> bool {\n    err.to_string().contains(\"did not receive response headers\")\n}","tryCatchPattern":"match open_sse_response(req).await {\n    Err(e) if is_header_stall_timeout(&e) => {\n        // retryable: backoff and try again before giving up\n        tokio::time::sleep(BACKOFF).await;\n        open_sse_response(req).await\n    }\n    other => other,\n}","preventionTips":["Unset CODEWHALE_FORCE_HTTP1 when your network supports HTTP/2 so both protocols remain available.","Configure proxies to allow long-lived SSE connections (no buffered inspection on streaming paths).","Keep open_timeout generous on high-latency networks.","Alert on provider status pages; stalls often correlate with incidents."],"tags":["network","sse","timeout","streaming"],"backgroundTag":"request-timeout","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"}