Skip to content

Commit bcd1d19

Browse files
authored
fix(title-generation): abort spawned tasks on drop instead of relying on handle drop (#2996)
1 parent 28b59e8 commit bcd1d19

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

crates/forge_app/src/hooks/title_generation.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ impl<S: AgentService> EventHandle<EventData<EndPayload>> for TitleGenerationHand
105105

106106
impl<S> Drop for TitleGenerationHandler<S> {
107107
fn drop(&mut self) {
108-
// Clearing the map drops all `JoinHandle`s (aborting the spawned
109-
// tasks) and `oneshot::Receiver`s. The tasks will observe a closed
110-
// channel on `tx.send()` and exit gracefully.
108+
// Explicitly abort every spawned task before clearing the map.
109+
// Dropping a `JoinHandle` does *not* abort the underlying Tokio task —
110+
// the task would keep running until completion. Calling `.abort()`
111+
// ensures the tasks are cancelled immediately so the runtime can
112+
// shut down cleanly without waiting for pending LLM calls.
113+
for entry in self.title_tasks.iter() {
114+
entry.handle.abort();
115+
}
111116
self.title_tasks.clear();
112117
}
113118
}

0 commit comments

Comments
 (0)