DioxusLabs/dioxus · error
Failed to serialize SSE event
Error message
Failed to serialize SSE event
What it means
An SSE event could not be serialized to JSON while building the server-sent-events stream. The event type fails Serialize (e.g. contains non-serializable fields), so the stream item cannot be produced.
Solutions
- Ensure the SSE event data is serializable (valid JSON/UTF-8) before sending; check the event payload for values that fail serialization.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/fullstack/src/payloads/sse.rs:318 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/e9aa2f960d899889.
Report an issue: GitHub.
Appendix: source
Thrown at packages/fullstack/src/payloads/sse.rs:318
Self {
_marker: std::marker::PhantomData,
client: None,
keep_alive: Some(KeepAlive::new().interval(Duration::from_secs(15))),
sse: Some(sse),
}
}
/// Create a `ServerEvents` from a `TryStream` of events.
pub fn from_stream<S>(stream: S) -> Self
where
S: TryStream<Ok = T, Error = BoxError> + Send + 'static,
T: Serialize,
{
let stream = stream.map_ok(|event| {
axum::response::sse::Event::default()
.json_data(event)
.expect("Failed to serialize SSE event")
});
let sse = axum::response::Sse::new(stream.boxed());
Self {
_marker: std::marker::PhantomData,
client: None,
keep_alive: Some(KeepAlive::new().interval(Duration::from_secs(15))),
sse: Some(sse),
}
}
/// Set the keep-alive configuration for the SSE connection.
///
/// A `None` value will disable the default `KeepAlive` of 15 seconds.
pub fn with_keep_alive(mut self, keep_alive: Option<KeepAlive>) -> Self {
self.keep_alive = keep_alive;
self
}
View on GitHub (pinned to 24f6a829df)