From dfb69e87fd3a010c365a49ffdeaa603668f06092 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 14:37:12 -0600 Subject: [PATCH 1/7] fix the test --- crates/turborepo-lib/src/run/watch.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/run/watch.rs b/crates/turborepo-lib/src/run/watch.rs index b50d8ed41dbe9..f86a7b70ff1ce 100644 --- a/crates/turborepo-lib/src/run/watch.rs +++ b/crates/turborepo-lib/src/run/watch.rs @@ -200,10 +200,11 @@ impl WatchClient { // if notify exits, then continue per usual // if persist exits, then we break out of loop with a select! { - _ = notify_run.notified() => {}, + biased; _ = persistent => { break; } + _ = notify_run.notified() => {}, } } else { notify_run.notified().await; From 32d7ea45b3e1a95a99aa4a652d91f689f413630b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 14:39:34 -0600 Subject: [PATCH 2/7] WIP 65b01 --- .../integration/tests/watch/persistent-exit.t | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/turborepo-tests/integration/tests/watch/persistent-exit.t b/turborepo-tests/integration/tests/watch/persistent-exit.t index ced498004d20c..3876410b8db18 100644 --- a/turborepo-tests/integration/tests/watch/persistent-exit.t +++ b/turborepo-tests/integration/tests/watch/persistent-exit.t @@ -14,12 +14,15 @@ Disabling daemon so this matches behavior when running test on CI web:dev: > echo server crashed && exit 1 web:dev: web:dev: server crashed - web:dev: npm ERR! Lifecycle script `dev` failed with error: - web:dev: npm ERR! Error: command failed - web:dev: npm ERR! in workspace: web - web:dev: npm ERR! at location: .* (re) - web:dev: ERROR: command finished with error: command .*npm(?:\.cmd)? run dev exited \(1\) (re) - web#dev: command .*npm(?:\.cmd)? run dev exited \(1\) (re) + web:dev: npm error Lifecycle script `dev` failed with error: + web:dev: npm error code 1 + web:dev: npm error path .* (re) + web:dev: npm error workspace web + web:dev: npm error location .* (re) + web:dev: npm error command failed + web:dev: npm error command bash -c echo server crashed && exit 1 + web:dev: ERROR: command finished with error: command .* (re) + web#dev: command .* (re) web:dev: cache bypass, force executing bfb830bdb7d49cb8 web:dev: web:dev: > dev From 9c2f02b533703eae15386b67426185184687082c Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 14:40:25 -0600 Subject: [PATCH 3/7] WIP a0f6d --- .../integration/tests/watch/persistent-exit.t | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/turborepo-tests/integration/tests/watch/persistent-exit.t b/turborepo-tests/integration/tests/watch/persistent-exit.t index 3876410b8db18..1e61739110695 100644 --- a/turborepo-tests/integration/tests/watch/persistent-exit.t +++ b/turborepo-tests/integration/tests/watch/persistent-exit.t @@ -23,18 +23,6 @@ Disabling daemon so this matches behavior when running test on CI web:dev: npm error command bash -c echo server crashed && exit 1 web:dev: ERROR: command finished with error: command .* (re) web#dev: command .* (re) - web:dev: cache bypass, force executing bfb830bdb7d49cb8 - web:dev: - web:dev: > dev - web:dev: > echo server crashed && exit 1 - web:dev: - web:dev: server crashed - web:dev: npm ERR! Lifecycle script `dev` failed with error: - web:dev: npm ERR! Error: command failed - web:dev: npm ERR! in workspace: web - web:dev: npm ERR! at location: .* (re) - web:dev: ERROR: command finished with error: command .*npm(?:\.cmd)? run dev exited \(1\) (re) - web#dev: command .*npm(?:\.cmd)? run dev exited \(1\) (re) x persistent tasks exited unexpectedly [1] From 85aa7d2cd0e3de99b8ad9ffe9a3d0d3871c8e675 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 14:41:14 -0600 Subject: [PATCH 4/7] WIP 76387 --- .../integration/tests/watch/persistent-exit.t | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/turborepo-tests/integration/tests/watch/persistent-exit.t b/turborepo-tests/integration/tests/watch/persistent-exit.t index 1e61739110695..d6f25bdd95ca2 100644 --- a/turborepo-tests/integration/tests/watch/persistent-exit.t +++ b/turborepo-tests/integration/tests/watch/persistent-exit.t @@ -14,15 +14,12 @@ Disabling daemon so this matches behavior when running test on CI web:dev: > echo server crashed && exit 1 web:dev: web:dev: server crashed - web:dev: npm error Lifecycle script `dev` failed with error: - web:dev: npm error code 1 - web:dev: npm error path .* (re) - web:dev: npm error workspace web - web:dev: npm error location .* (re) - web:dev: npm error command failed - web:dev: npm error command bash -c echo server crashed && exit 1 - web:dev: ERROR: command finished with error: command .* (re) - web#dev: command .* (re) + web:dev: npm ERR! Lifecycle script `dev` failed with error: + web:dev: npm ERR! Error: command failed + web:dev: npm ERR! in workspace: web + web:dev: npm ERR! at location: .* (re) + web:dev: ERROR: command finished with error: command .*npm(?:\.cmd)? run dev exited \(1\) (re) + web#dev: command .*npm(?:\.cmd)? run dev exited \(1\) (re) x persistent tasks exited unexpectedly - [1] + [1] \ No newline at end of file From b9fe32629263876d5d2850a8def44d330f1d4fd6 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 16:37:34 -0600 Subject: [PATCH 5/7] maybe --- crates/turborepo-lib/src/run/cache.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/run/cache.rs b/crates/turborepo-lib/src/run/cache.rs index 4fbbf3ff0697e..e12664b0c1d49 100644 --- a/crates/turborepo-lib/src/run/cache.rs +++ b/crates/turborepo-lib/src/run/cache.rs @@ -126,6 +126,7 @@ impl RunCache { task_id, task_output_logs, caching_disabled, + persistent: task_definition.persistent, log_file_path, daemon_client: self.daemon_client.clone(), ui: self.ui, @@ -153,6 +154,7 @@ pub struct TaskCache { hash: String, task_output_logs: OutputLogsMode, caching_disabled: bool, + persistent: bool, log_file_path: AbsoluteSystemPathBuf, daemon_client: Option>, ui: ColorConfig, @@ -223,7 +225,8 @@ impl TaskCache { if !matches!( self.task_output_logs, OutputLogsMode::None | OutputLogsMode::ErrorsOnly - ) { + ) && !self.persistent + { terminal_output.status( &format!( "cache bypass, force executing {}", From 9eaeb386bf6c422683bef9392ccb33aec1dc5f82 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 18:12:46 -0600 Subject: [PATCH 6/7] maybe? --- crates/turborepo-lib/src/run/cache.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/turborepo-lib/src/run/cache.rs b/crates/turborepo-lib/src/run/cache.rs index e12664b0c1d49..4fbbf3ff0697e 100644 --- a/crates/turborepo-lib/src/run/cache.rs +++ b/crates/turborepo-lib/src/run/cache.rs @@ -126,7 +126,6 @@ impl RunCache { task_id, task_output_logs, caching_disabled, - persistent: task_definition.persistent, log_file_path, daemon_client: self.daemon_client.clone(), ui: self.ui, @@ -154,7 +153,6 @@ pub struct TaskCache { hash: String, task_output_logs: OutputLogsMode, caching_disabled: bool, - persistent: bool, log_file_path: AbsoluteSystemPathBuf, daemon_client: Option>, ui: ColorConfig, @@ -225,8 +223,7 @@ impl TaskCache { if !matches!( self.task_output_logs, OutputLogsMode::None | OutputLogsMode::ErrorsOnly - ) && !self.persistent - { + ) { terminal_output.status( &format!( "cache bypass, force executing {}", From cc3331f4232f6ac872d15a4d87a8cd58274beb13 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Jun 2025 18:40:17 -0600 Subject: [PATCH 7/7] Maybe?? --- crates/turborepo-lib/src/run/watch.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/turborepo-lib/src/run/watch.rs b/crates/turborepo-lib/src/run/watch.rs index f86a7b70ff1ce..624a72363be3f 100644 --- a/crates/turborepo-lib/src/run/watch.rs +++ b/crates/turborepo-lib/src/run/watch.rs @@ -182,8 +182,24 @@ impl WatchClient { let notify_event = notify_run.clone(); let event_fut = async { + let mut first_rediscover = true; while let Some(event) = events.next().await { let event = event?; + + // Skip the first RediscoverPackages event which is sent immediately by the + // daemon when we connect. The file watcher will send the real + // one. + if first_rediscover { + if matches!( + event.event, + Some(proto::package_change_event::Event::RediscoverPackages(_)) + ) { + first_rediscover = false; + continue; + } + first_rediscover = false; + } + Self::handle_change_event(&changed_packages, event.event.unwrap())?; notify_event.notify_one(); }