Skip to content

Commit f1b1eb1

Browse files
authored
fix the test (#10585)
I'm 0% certain that this is a structurally sound change - but it does fix the logs regression in #8858.
1 parent 98851e3 commit f1b1eb1

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

crates/turborepo-lib/src/run/watch.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,24 @@ impl WatchClient {
182182
let notify_event = notify_run.clone();
183183

184184
let event_fut = async {
185+
let mut first_rediscover = true;
185186
while let Some(event) = events.next().await {
186187
let event = event?;
188+
189+
// Skip the first RediscoverPackages event which is sent immediately by the
190+
// daemon when we connect. The file watcher will send the real
191+
// one.
192+
if first_rediscover {
193+
if matches!(
194+
event.event,
195+
Some(proto::package_change_event::Event::RediscoverPackages(_))
196+
) {
197+
first_rediscover = false;
198+
continue;
199+
}
200+
first_rediscover = false;
201+
}
202+
187203
Self::handle_change_event(&changed_packages, event.event.unwrap())?;
188204
notify_event.notify_one();
189205
}
@@ -200,10 +216,11 @@ impl WatchClient {
200216
// if notify exits, then continue per usual
201217
// if persist exits, then we break out of loop with a
202218
select! {
203-
_ = notify_run.notified() => {},
219+
biased;
204220
_ = persistent => {
205221
break;
206222
}
223+
_ = notify_run.notified() => {},
207224
}
208225
} else {
209226
notify_run.notified().await;

turborepo-tests/integration/tests/watch/persistent-exit.t

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,7 @@ Disabling daemon so this matches behavior when running test on CI
1919
web:dev: npm ERR! in workspace: web
2020
web:dev: npm ERR! at location: .* (re)
2121
web:dev: ERROR: command finished with error: command .*npm(?:\.cmd)? run dev exited \(1\) (re)
22-
web#dev: command .*npm(?:\.cmd)? run dev exited \(1\) (re)
23-
web:dev: cache bypass, force executing bfb830bdb7d49cb8
24-
web:dev:
25-
web:dev: > dev
26-
web:dev: > echo server crashed && exit 1
27-
web:dev:
28-
web:dev: server crashed
29-
web:dev: npm ERR! Lifecycle script `dev` failed with error:
30-
web:dev: npm ERR! Error: command failed
31-
web:dev: npm ERR! in workspace: web
32-
web:dev: npm ERR! at location: .* (re)
33-
web:dev: ERROR: command finished with error: command .*npm(?:\.cmd)? run dev exited \(1\) (re)
3422
web#dev: command .*npm(?:\.cmd)? run dev exited \(1\) (re)
3523
x persistent tasks exited unexpectedly
3624

37-
[1]
25+
[1]

0 commit comments

Comments
 (0)