Skip to content

Commit 8bf1638

Browse files
authored
stop sending messages on closed websockets (#881)
1 parent 805caf4 commit 8bf1638

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

common/src/typed_socket/server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ pub async fn handle_messages<T: ChannelMessage>(
3030
SocketAction::Send(msg) => {
3131
let msg = Message::Text(serde_json::to_string(&msg).expect("Always serializable."));
3232
if let Err(err) = socket.send(msg.clone()).await {
33-
tracing::error!(?err, message=?msg, "Failed to send message on websocket.");
33+
tracing::warn!(?err, ?msg, "Failed to send message on websocket.");
34+
// If the connection is already closed, the error is unrecoverable,
35+
// and we should stop trying to send messages.
36+
break;
3437
}
3538
}
3639
SocketAction::Close => {

0 commit comments

Comments
 (0)