Skip to content

Commit

Permalink
chore(watch): warn if daemon is disabled (#9407)
Browse files Browse the repository at this point in the history
### Description

Closes #9401

`turbo watch` cannot function without the daemon, we should warn users
of this if they have tried to disable the daemon.

We could error if the daemon is disabled, but that would lead to awkward
behavior if it is disabled in `turbo.json`. It's possible to want the
daemon disabled for `turbo run`, but still want to use `turbo watch`.

### Testing Instructions

Attempt running watch with an explicit request to disable the daemon:
```
[1 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo_dev --no-daemon watch @turbo/types#build            
 WARNING  No locally installed `turbo` found. Using version: 2.2.4-canary.8.
turbo 2.2.4-canary.8

 WARNING  daemon is required for watch, ignoring request to disable daemon
• Packages in scope: @turbo-internal/top-issues-gh-action, @turbo/benchmark, @turbo/codemod, @turbo/eslint-config, @turbo/exe-stub, @turbo/gen, @turbo/telemetry, @turbo/test-utils, @turbo/tsconfig, @turbo/types, @turbo/utils, @turbo/workspaces, @turborepo-examples-tests/basic, @turborepo-examples-tests/design-system, @turborepo-examples-tests/kitchen-sink, @turborepo-examples-tests/non-monorepo, @turborepo-examples-tests/with-berry, @turborepo-examples-tests/with-changesets, @turborepo-examples-tests/with-npm, @turborepo-examples-tests/with-react-native-web, @turborepo-examples-tests/with-rollup, @turborepo-examples-tests/with-svelte, @turborepo-examples-tests/with-tailwind, @turborepo-examples-tests/with-vite, @turborepo-examples-tests/with-yarn, cargo-sweep-action, cli, create-turbo, eslint-config-turbo, eslint-plugin-turbo, prysk, turbo-ignore, turbo-vsc, turborepo-examples, turborepo-repository, turborepo-tests-helpers, turborepo-tests-integration
• Running @turbo/types#build in 37 packages
• Remote caching enabled
┌ @turbo/types#build > cache miss, executing 305999608c9295f1 
│ 
│ 
│ > @turbo/types@2.2.4-canary.8 build /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsc && pnpm generate-schema
│ 
│ 
│ > @turbo/types@2.2.4-canary.8 generate-schema /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsx scripts/generate-schema.ts
└────>
  × watch interrupted due to signal
```
  • Loading branch information
chris-olszewski authored Nov 13, 2024
1 parent ad56af9 commit 931e636
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/turborepo-lib/src/run/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use futures::StreamExt;
use miette::{Diagnostic, SourceSpan};
use thiserror::Error;
use tokio::{select, sync::Notify, task::JoinHandle};
use tracing::{instrument, trace};
use tracing::{instrument, trace, warn};
use turborepo_repository::package_graph::PackageName;
use turborepo_telemetry::events::command::CommandEventBuilder;
use turborepo_ui::sender::UISender;
Expand Down Expand Up @@ -113,12 +113,16 @@ impl WatchClient {
pub async fn new(base: CommandBase, telemetry: CommandEventBuilder) -> Result<Self, Error> {
let signal = commands::run::get_signal()?;
let handler = SignalHandler::new(signal);
let root_turbo_json_path = base.config()?.root_turbo_json_path(&base.repo_root);
let config = base.config()?;
let root_turbo_json_path = config.root_turbo_json_path(&base.repo_root);
if root_turbo_json_path != base.repo_root.join_component(CONFIG_FILE) {
return Err(Error::NonStandardTurboJsonPath(
root_turbo_json_path.to_string(),
));
}
if matches!(config.daemon(), Some(false)) {
warn!("daemon is required for watch, ignoring request to disable daemon");
}

let Some(Command::Watch(execution_args)) = &base.args().command else {
unreachable!()
Expand Down

0 comments on commit 931e636

Please sign in to comment.