Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Apr 18, 2024
1 parent 1682062 commit c69ac3a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/turborepo-lib/src/run/watch.rs
Expand Up @@ -73,7 +73,7 @@ impl WatchClient {
execution_args: execution_args.clone(),
});

let mut main_run_handle: Option<JoinHandle<_>> = None;
let mut persistent_tasks_handle: Option<JoinHandle<_>> = None;

let run = RunBuilder::new(new_base)?
.build(&handler, telemetry.clone())
Expand Down Expand Up @@ -112,7 +112,7 @@ impl WatchClient {
&base,
&telemetry,
&handler,
&mut main_run_handle,
&mut persistent_tasks_handle,
has_persistent_tasks,
sender.clone(),
)
Expand Down Expand Up @@ -143,7 +143,7 @@ impl WatchClient {
base: &CommandBase,
telemetry: &CommandEventBuilder,
handler: &SignalHandler,
main_run_handle: &mut Option<JoinHandle<Result<i32, run::error::Error>>>,
persistent_tasks_handle: &mut Option<JoinHandle<Result<i32, run::error::Error>>>,
has_persistent_tasks: bool,
ui_sender: Option<AppSender>,
) -> Result<(), Error> {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c69ac3a

Please sign in to comment.