{"record":{"id":"148f7ad3dc4991bf","repo":"Hmbown/CodeWhale","slug":"sse-stream-request-did-not-receive-response-header-148f7a","errorCode":null,"errorMessage":"SSE stream request did not receive response headers after {}s (HTTP/2 and HTTP/1.1). `codewhale doctor` can still pass when non-streaming requests work; try `CODEWHALE_FORCE_HTTP1=1` and rerun `codewhale`.","messagePattern":"SSE stream request did not receive response headers after (.+?)s \\(HTTP/2 and HTTP/1\\.1\\)\\. `codewhale doctor` can still pass when non-streaming requests work; 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":210,"sourceCode":"            }\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),\n        Ok(Err(err)) => Err(h1_fallback_error(err)),\n        // Typed, not a bare string: a header stall is a transport\n        // failure, and `LlmError::NetworkError` is what the shared\n        // retry layer recognizes as retryable. As an untyped anyhow\n        // error this killed the whole turn outright.\n        Err(_elapsed) => Err(anyhow::Error::new(LlmError::NetworkError(format!(\n            \"SSE stream request did not receive response headers after {}s \\\n             (HTTP/2 and HTTP/1.1). `codewhale doctor` can still pass when \\\n             non-streaming requests work; try `CODEWHALE_FORCE_HTTP1=1` and \\\n             rerun `codewhale`.\",\n            open_req.open_timeout.as_secs()\n        )))),\n    }\n}\n\n/// Format a stable idle-timeout message shared across adapters.\n#[must_use]\npub fn idle_timeout_message(\n    idle: Duration,\n    bytes_received: usize,\n    stream_age: Duration,\n    since_last_chunk: Duration,\n) -> String {\n    format!(","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client/stream_entry.rs#L192-L228","documentation":"`open_sse_response` bounds the SSE open. When no response headers arrive within the timeout and both protocols have been tried (dual HTTP/2 + HTTP/1.1 policy), it raises this `LlmError::NetworkError`. The typed error (not a bare string) matters: `LlmError::NetworkError` is what the shared retry layer treats as retryable, so a header stall no longer kills the whole turn.","triggerScenarios":"Default (dual HTTP/2 + HTTP/1.1) streaming policy where the endpoint returns neither HTTP/2 nor HTTP/1.1 response headers within `open_req.open_timeout` seconds.","commonSituations":"Restrictive corporate proxies that hold streaming requests open but never respond; Windows TLS interception; providers silently dropping the request; misconfigured local gateways.","solutions":["Test the endpoint with `curl -N` to the streaming URL to see whether headers ever arrive — if not, the network path is the problem.","Check and reconfigure proxy/VPN/TLS-interception software to allow streaming responses from the provider host.","Retry; the error is retryable and transient stalls often pass on a second attempt.","Run `codewhale doctor` to separate streaming issues from general connectivity."],"exampleFix":"# before\n$ codewhale\nSSE stream request did not receive response headers after 30s (HTTP/2 and HTTP/1.1) ...\n# after\n$ curl -N -H 'Accept: text/event-stream' https://<provider>/v1/...   # diagnose; fix proxy, then rerun","handlingStrategy":"retry","validationCode":"let reachable = tokio::net::TcpStream::connect((host, 443)).await.is_ok();\nif !reachable { eprintln!(\"provider host unreachable; check firewall/proxy\"); }","typeGuard":"fn is_dual_protocol_header_timeout(err: &anyhow::Error) -> bool {\n    err.to_string().contains(\"HTTP/2 and HTTP/1.1\")\n        && err.to_string().contains(\"did not receive response headers\")\n}","tryCatchPattern":"if let Err(e) = open_sse_response(req).await {\n    if is_dual_protocol_header_timeout(&e) {\n        // typed NetworkError is retryable; retry with bounded attempts\n        for _ in 0..2 { if open_sse_response(req).await.is_ok() { break; } tokio::time::sleep(BACKOFF).await; }\n    } else { return Err(e); }\n}","preventionTips":["Fix middlebox/TLS-interception configs that swallow streaming responses.","Test with `curl -N` to the streaming endpoint after any network change.","Don't reduce open_timeout below your network's worst-case TLS+proxy latency.","Monitor `codewhale doctor` results as part of environment onboarding."],"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"}