sigoden/aichat · error
{err}
Error message
{err} What it means
Transport-level failure inside the SSE loop that is not a status or content-type problem: connection reset mid-stream, invalid UTF-8 in event data, or reqwest event-source protocol errors. The underlying error is re-raised verbatim after the match, so the message is whatever the event-source crate produced.
Solutions
- Retry idempotent chat requests on connection reset with exponential backoff
- Check network stability and any corporate proxy that may terminate long-lived SSE connections
- Preserve partial output already received before deciding whether to retry from scratch or resume
- Report the underlying error string to diagnostics since it originates outside this codebase
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/client/stream.rs:134 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/7a213e29a273b5d4.
Report an issue: GitHub.
Appendix: source
Thrown at src/client/stream.rs:134
Ok(data) => data,
Err(_) => {
bail!(
"Invalid response data: {text} (status: {})",
status.as_u16()
);
}
};
catch_error(&data, status.as_u16())?;
}
EventSourceError::InvalidContentType(header_value, res) => {
let text = res.text().await?;
bail!(
"Invalid response event-stream. content-type: {}, data: {text}",
header_value.to_str().unwrap_or_default()
);
}
_ => {
bail!("{}", err);
}
}
es.close();
}
}
}
Ok(())
}
pub async fn json_stream<S, F, E>(mut stream: S, mut handle: F) -> Result<()>
where
S: Stream<Item = Result<bytes::Bytes, E>> + Unpin,
F: FnMut(&str) -> Result<()>,
E: std::error::Error,
{
let mut parser = JsonStreamParser::default();
let mut unparsed_bytes = vec![];
while let Some(chunk_bytes) = stream.next().await {View on GitHub (pinned to 82976d349a)