Hmbown/CodeWhale · error · LlmError::NetworkError
SSE stream request failed after HTTP/1.1 fallback
Error message
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`. What it means
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.
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.
Example fix
# before $ codewhale SSE stream request failed after HTTP/1.1 fallback: ... # after $ CODEWHALE_FORCE_HTTP1=1 codewhale # or fix proxy allowlist for streaming
Defensive patterns
Strategy: retry
Validate before calling
// pre-check streaming reachability
let ok = std::process::Command::new("curl")
.args(["-sS", "-N", "--max-time", "10", "-H", "Accept: text/event-stream", &base_url])
.status().map(|s| s.success()).unwrap_or(false); Type guard
fn is_stream_transport_failure(err: &anyhow::Error) -> bool {
err.downcast_ref::<LlmError>().map_or(false, |e|
matches!(e, LlmError::NetworkError(_) | LlmError::Timeout(_)))
} Try / catch
match open_sse_response(req).await {
Err(e) if is_stream_transport_failure(&e) => {
// fallback: retry with backoff, then surface `codewhale doctor` hint
if let Err(e2) = open_sse_response(req).await {
eprintln!("Streaming failed twice: {e2}. Run `codewhale doctor`.");
}
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: `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).
Common situations: 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.
Related errors
- runtime event stream ended before turn.completed
- Runtime event stream ended inside a frame
- runtime SSE frame exceeded
- 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/527e6fdcbf64db2c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client/stream_entry.rs:144
|| reqwest_error.is_timeout()
|| reqwest_error.is_request();
}
should_retry_with_h1(policy, &format!("{err:#}"))
}
/// Preserve provider-semantic failures returned by the H1 attempt. Only a
/// transport failure should be normalized into the shared retryable network
/// error; otherwise an auth or invalid-request failure could be retried as if
/// switching protocols had failed.
fn h1_fallback_error(err: anyhow::Error) -> anyhow::Error {
if let Some(llm_error) = err.downcast_ref::<LlmError>()
&& !matches!(llm_error, LlmError::NetworkError(_) | LlmError::Timeout(_))
{
return err;
}
anyhow::Error::new(LlmError::NetworkError(format!(
"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`."
)))
}
/// Open an SSE response through the shared transport policy.
///
/// `attempt` builds and sends one wire-specific request on the client
/// selected for the given policy (via [`client_for_policy`]); everything
/// transport-shared lives here:
///
/// - the response-header wait is bounded by `open_req.open_timeout`;
/// - a classified transport failure or header stall on the dual client
/// retries exactly once on the HTTP/1.1 twin;
/// - a failure on an already H1-pinned request never retries;
/// - once response headers have been received the seam never retries —
/// body/stream errors belong to the adapter's decode loop.View on GitHub (pinned to 73e0f67d83)