From c69ac3a0a767ce113afbbcd7b235cf193de0f7ae Mon Sep 17 00:00:00 2001 From: nicholaslyang Date: Thu, 18 Apr 2024 12:58:59 -0400 Subject: [PATCH] Fix --- crates/turborepo-lib/src/run/watch.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/turborepo-lib/src/run/watch.rs b/crates/turborepo-lib/src/run/watch.rs index c449e80ef3e1c..52aa307f38507 100644 --- a/crates/turborepo-lib/src/run/watch.rs +++ b/crates/turborepo-lib/src/run/watch.rs @@ -73,7 +73,7 @@ impl WatchClient { execution_args: execution_args.clone(), }); - let mut main_run_handle: Option> = None; + let mut persistent_tasks_handle: Option> = None; let run = RunBuilder::new(new_base)? .build(&handler, telemetry.clone()) @@ -112,7 +112,7 @@ impl WatchClient { &base, &telemetry, &handler, - &mut main_run_handle, + &mut persistent_tasks_handle, has_persistent_tasks, sender.clone(), ) @@ -143,7 +143,7 @@ impl WatchClient { base: &CommandBase, telemetry: &CommandEventBuilder, handler: &SignalHandler, - main_run_handle: &mut Option>>, + persistent_tasks_handle: &mut Option>>, has_persistent_tasks: bool, ui_sender: Option, ) -> Result<(), Error> { @@ -233,15 +233,16 @@ impl WatchClient { if has_persistent_tasks { // Abort old run - if let Some(run) = main_run_handle.take() { + if let Some(run) = persistent_tasks_handle.take() { run.abort(); } let persistent_run = run.create_run_for_persistent_tasks(); // If we have persistent tasks, we run them on a separate thread // since persistent tasks don't finish - *main_run_handle = Some(tokio::spawn(async move { - persistent_run.run(ui_sender.clone()).await + let persistent_run_ui_sender = ui_sender.clone(); + *persistent_tasks_handle = Some(tokio::spawn(async move { + persistent_run.run(persistent_run_ui_sender.clone()).await })); // But we still run the regular tasks blocking