drain completed tasks and log webhook queue stats

This commit is contained in:
2026-06-10 18:19:18 +00:00
parent 6599c20c30
commit 3d751ae6c6
+10 -2
View File
@@ -61,6 +61,14 @@ impl Bot {
let mut tasks = tokio::task::JoinSet::new();
while let Some(wb) = rx.recv().await {
// Drain completed tasks to avoid the JoinSet growing unbounded
while let Some(res) = tasks.try_join_next() {
if let Err(e) = res {
error!("Task panicked: {e}");
}
}
info!(queued = rx.len(), active = tasks.len(), "Webhook received");
let permit = sem.clone().acquire_owned().await?;
let self_clone = self.clone();
@@ -70,8 +78,8 @@ impl Bot {
});
}
// Le channel est fermé : on attend que les tâches en cours se terminent
// proprement avant de rendre la main
// When all webhook tasks have completed, we can safely exit
// properly before returning
while let Some(res) = tasks.join_next().await {
if let Err(e) = res {
error!("Task panicked: {e}");