Hmbown/CodeWhale · error · LlmError::NetworkError
SSE stream request did not receive response headers after
Error message
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`. What it means
`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.
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.
Example fix
# before $ codewhale SSE stream request did not receive response headers after 30s (HTTP/2 and HTTP/1.1) ... # after $ curl -N -H 'Accept: text/event-stream' https://<provider>/v1/... # diagnose; fix proxy, then rerun
Defensive patterns
Strategy: retry
Validate before calling
let reachable = tokio::net::TcpStream::connect((host, 443)).await.is_ok();
if !reachable { eprintln!("provider host unreachable; check firewall/proxy"); } Type guard
fn is_dual_protocol_header_timeout(err: &anyhow::Error) -> bool {
err.to_string().contains("HTTP/2 and HTTP/1.1")
&& err.to_string().contains("did not receive response headers")
} Try / catch
if let Err(e) = open_sse_response(req).await {
if is_dual_protocol_header_timeout(&e) {
// typed NetworkError is retryable; retry with bounded attempts
for _ in 0..2 { if open_sse_response(req).await.is_ok() { break; } tokio::time::sleep(BACKOFF).await; }
} else { return Err(e); }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Restrictive corporate proxies that hold streaming requests open but never respond; Windows TLS interception; providers silently dropping the request; misconfigured local gateways.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- SSE stream idle timeout after
- SSE stream idle timeout after
- SSE stream idle timeout after
- SSE stream idle timeout after
- SSE stream idle timeout after
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/148f7ad3dc4991bf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client/stream_entry.rs:210
}
"response-header timeout"
}
};
// No response body exists yet, so switching protocols and replaying the
// request is safe. The policy guard above keeps this to exactly one retry.
let h1_req = open_req.clone().with_h1_only();
crate::logging::warn(format!(
"SSE stream {fallback_reason}; retrying once with HTTP/1.1"
));
match tokio::time::timeout(h1_req.open_timeout, attempt(h1_req.policy)).await {
Ok(Ok(response)) => Ok(response),
Ok(Err(err)) => Err(h1_fallback_error(err)),
// Typed, not a bare string: a header stall is a transport
// failure, and `LlmError::NetworkError` is what the shared
// retry layer recognizes as retryable. As an untyped anyhow
// error this killed the whole turn outright.
Err(_elapsed) => Err(anyhow::Error::new(LlmError::NetworkError(format!(
"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`.",
open_req.open_timeout.as_secs()
)))),
}
}
/// Format a stable idle-timeout message shared across adapters.
#[must_use]
pub fn idle_timeout_message(
idle: Duration,
bytes_received: usize,
stream_age: Duration,
since_last_chunk: Duration,
) -> String {
format!(View on GitHub (pinned to 73e0f67d83)