Skip to content

Commit

Permalink
Debugging watch mode bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Mar 4, 2024
1 parent 840de5b commit ccfb9c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/run/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl RunCache {

pub async fn shutdown_cache(&self) {
// Ignore errors coming from cache already shutting down
self.cache.shutdown().await.ok();
let _ = tokio::time::timeout(Duration::from_secs(30), self.cache.shutdown()).await;
}
}

Expand Down
19 changes: 14 additions & 5 deletions crates/turborepo-lib/src/run/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ use tokio::{select, task::JoinHandle};
use turborepo_telemetry::events::command::CommandEventBuilder;

use crate::{
cli::{Command, RunArgs},
cli::{Command, OutputLogsMode, RunArgs},
commands,
commands::CommandBase,
daemon::{proto, DaemonConnectorError, DaemonError},
get_version, run,
get_version,
opts::Opts,

Check warning on line 14 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / JS Native Package Tests (ubuntu, self-hosted, linux, x64, metal)

unused import: `opts::Opts`

Check warning on line 14 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / JS Native Package Tests (macos, macos-latest)

unused import: `opts::Opts`

Check warning on line 14 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, self-hosted, linux, x64, metal)

unused import: `opts::Opts`

Check warning on line 14 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

unused import: `opts::Opts`

Check warning on line 14 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

unused import: `opts::Opts`
run,
signal::SignalHandler,
Args, DaemonConnector, DaemonPaths,
};
Expand All @@ -35,8 +37,6 @@ pub enum Error {

impl WatchClient {
pub async fn start(base: CommandBase, telemetry: CommandEventBuilder) -> Result<(), Error> {
let signal = commands::run::get_signal()?;
let handler = SignalHandler::new(signal);
let connector = DaemonConnector {
can_start_server: true,
can_kill_server: true,
Expand All @@ -49,6 +49,9 @@ impl WatchClient {
let mut current_runs: HashMap<String, JoinHandle<Result<i32, run::Error>>> = HashMap::new();

loop {
let signal = commands::run::get_signal()?;

Check failure on line 52 in crates/turborepo-lib/src/run/watch.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

the `?` operator can only be applied to values that implement `Try`
let handler = SignalHandler::new(signal);

let Some(subscriber) = handler.subscribe() else {
tracing::warn!("failed to subscribe to signal handler, shutting down");
break;
Expand Down Expand Up @@ -94,11 +97,16 @@ impl WatchClient {
let args = Args {
command: Some(Command::Run(Box::new(RunArgs {
tasks: base.args().get_tasks().to_owned(),
filter: vec![package.clone()],
filter: vec![format!("...{}", package)],
output_logs: Some(OutputLogsMode::None),
..Default::default()
}))),

..Args::default()
};

println!("running `{:#?}`", args);

let new_base = CommandBase::new(
args,
base.repo_root.clone(),
Expand All @@ -125,6 +133,7 @@ impl WatchClient {
let args = Args {
command: Some(Command::Run(Box::new(RunArgs {
tasks: base.args().get_tasks().to_owned(),
output_logs: Some(OutputLogsMode::None),
..Default::default()
}))),
..Args::default()
Expand Down

0 comments on commit ccfb9c7

Please sign in to comment.