Skip to content

Commit

Permalink
fix(watch): shut down persistent tasks when we exit watch mode (#9405)
Browse files Browse the repository at this point in the history
### Description

This was causing a nasty non-deterministic bug where sending a SIGINT
would cause the turbo process to hang and not exit cleanly...sometimes.

### Testing Instructions

Try running `turbo watch dev --skip-infer` on create-turbo and
cancelling it with Ctrl-C
  • Loading branch information
NicholasLYang authored Nov 7, 2024
1 parent 865cf60 commit b65ff15
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/turborepo-lib/src/run/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ impl WatchClient {
biased;
_ = signal_subscriber.listen() => {
tracing::info!("shutting down");

if let Some(RunHandle { stopper, run_task }) = self.persistent_tasks_handle.take() {
// Shut down the tasks for the run
stopper.stop().await;
// Run should exit shortly after we stop all child tasks, wait for it to finish
// to ensure all messages are flushed.
let _ = run_task.await;
}
Err(Error::SignalInterrupt)
}
result = event_fut => {
Expand Down

0 comments on commit b65ff15

Please sign in to comment.