From 9d255d7f174800339510f84750478c879cab291b Mon Sep 17 00:00:00 2001 From: Tushar Date: Tue, 14 Apr 2026 12:31:11 +0530 Subject: [PATCH] fix(title-generation): abort spawned tasks on drop instead of relying on handle drop --- crates/forge_app/src/hooks/title_generation.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/forge_app/src/hooks/title_generation.rs b/crates/forge_app/src/hooks/title_generation.rs index 262b35bdcf..5984ccab52 100644 --- a/crates/forge_app/src/hooks/title_generation.rs +++ b/crates/forge_app/src/hooks/title_generation.rs @@ -105,9 +105,14 @@ impl EventHandle> for TitleGenerationHand impl Drop for TitleGenerationHandler { fn drop(&mut self) { - // Clearing the map drops all `JoinHandle`s (aborting the spawned - // tasks) and `oneshot::Receiver`s. The tasks will observe a closed - // channel on `tx.send()` and exit gracefully. + // Explicitly abort every spawned task before clearing the map. + // Dropping a `JoinHandle` does *not* abort the underlying Tokio task — + // the task would keep running until completion. Calling `.abort()` + // ensures the tasks are cancelled immediately so the runtime can + // shut down cleanly without waiting for pending LLM calls. + for entry in self.title_tasks.iter() { + entry.handle.abort(); + } self.title_tasks.clear(); } }