DioxusLabs/dioxus · error · WebsocketError
Failed to serialize message
Error message
Failed to serialize message
What it means
Sink::start_send failure for TypedWebsocket on the server: E::to_bytes could not serialize the outgoing Out message into axum's ws Message, so WebsocketError with this message is returned to the caller of send. The faulting input is the message value that the chosen Encoding cannot serialize.
Source
Thrown at packages/fullstack/src/payloads/websocket.rs:840
}
}
}
#[cfg(feature = "server")]
impl<In: DeserializeOwned, Out: Serialize, E: Encoding> Sink<Out> for TypedWebsocket<In, Out, E> {
type Error = WebsocketError;
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Pin::new(&mut self.inner)
.poll_ready(cx)
.map_err(|_| WebsocketError::AlreadyClosed)
}
fn start_send(mut self: Pin<&mut Self>, item: Out) -> Result<(), Self::Error> {
use axum::extract::ws::Message;
let to_bytes = E::to_bytes(&item).ok_or_else(|| {
WebsocketError::Serialization(anyhow::anyhow!("Failed to serialize message").into())
})?;
Pin::new(&mut self.inner)
.start_send(Message::Binary(to_bytes))
.map_err(|_| WebsocketError::AlreadyClosed)
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Pin::new(&mut self.inner)
.poll_flush(cx)
.map_err(|_| WebsocketError::AlreadyClosed)
}
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Pin::new(&mut self.inner)
.poll_close(cx)
.map_err(|_| WebsocketError::AlreadyClosed)
}View on GitHub (pinned to 24f6a829df)
Solutions
- The websocket message could not be serialized. Ensure the message type implements Serialize and contains valid data.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/fullstack/src/payloads/websocket.rs:840 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/ec5883c0ab6bd06b.
Report an issue: GitHub.