fix: update SSEActor error logging (#2052)
Co-authored-by: Jo Kelly-Fenton <jkellyfenton@spotify.com>
This commit is contained in:
@@ -118,6 +118,14 @@ impl PendingRequests {
|
|||||||
pub async fn clear(&self) {
|
pub async fn clear(&self) {
|
||||||
self.requests.write().await.clear();
|
self.requests.write().await.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn len(&self) -> usize {
|
||||||
|
self.requests.read().await.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn is_empty(&self) -> bool {
|
||||||
|
self.len().await == 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod stdio;
|
pub mod stdio;
|
||||||
|
|||||||
@@ -210,8 +210,13 @@ impl SseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mpsc channel closed => no more outgoing messages
|
// mpsc channel closed => no more outgoing messages
|
||||||
tracing::error!("SseActor: outgoing message loop ended. Clearing pending requests.");
|
let pending = pending_requests.len().await;
|
||||||
pending_requests.clear().await;
|
if pending > 0 {
|
||||||
|
tracing::error!("SSE stream ended or encountered an error with {pending} unfulfilled pending requests.");
|
||||||
|
pending_requests.clear().await;
|
||||||
|
} else {
|
||||||
|
tracing::info!("SseActor shutdown cleanly. No pending requests.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user