fix: update SSEActor error logging (#2052)

Co-authored-by: Jo Kelly-Fenton <jkellyfenton@spotify.com>
This commit is contained in:
jokellyfenton
2025-04-07 15:26:22 +01:00
committed by GitHub
parent c719518683
commit 45c1c3d183
2 changed files with 15 additions and 2 deletions

View File

@@ -118,6 +118,14 @@ impl PendingRequests {
pub async fn clear(&self) {
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;

View File

@@ -210,8 +210,13 @@ impl SseActor {
}
// mpsc channel closed => no more outgoing messages
tracing::error!("SseActor: outgoing message loop ended. Clearing pending requests.");
pending_requests.clear().await;
let pending = pending_requests.len().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.");
}
}
}