Skip to content

Commit

Permalink
Replace heartbeat events with checking if the channed 'is_closed'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsibbison-square committed Nov 28, 2024
1 parent a840942 commit b0a5bcf
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions crates/goose-server/src/routes/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ impl ProtocolFormatter {
});
format!("d:{}\n", finish)
}

fn heartbeat() -> String {
"2:[]\n".to_string()
}
}

async fn stream_message(
Expand Down Expand Up @@ -317,17 +313,8 @@ async fn handler(
break;
}
Err(_) => { // Heartbeat, used to detect disconnected clients and then end running tools.
if let Err(e) = tx.try_send(ProtocolFormatter::heartbeat()) {
match e {
mpsc::error::TrySendError::Closed(_) => {
// Client has disconnected, end the stream and close running tools (works by ending this process).
break;
}
mpsc::error::TrySendError::Full(_) => {
tracing::warn!("Error sending heartbeat message through channel: {}", e);
continue;
}
}
if tx.is_closed() {
break;
}
continue;
}
Expand Down

0 comments on commit b0a5bcf

Please sign in to comment.