Skip to content

Commit

Permalink
chore(daemon) disable daemon workspace discovery (#6695)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Olszewski <Chris Olszewski>
  • Loading branch information
chris-olszewski authored Dec 5, 2023
1 parent 380b3a2 commit 7a18c96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
19 changes: 6 additions & 13 deletions crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
collections::HashSet,
io::{IsTerminal, Write},
sync::Arc,
time::{Duration, SystemTime},
time::SystemTime,
};

pub use cache::{RunCache, TaskCache};
Expand All @@ -27,7 +27,7 @@ use turborepo_cache::{AsyncCache, RemoteCacheOpts};
use turborepo_ci::Vendor;
use turborepo_env::EnvironmentVariableMap;
use turborepo_repository::{
discovery::{FallbackPackageDiscovery, LocalPackageDiscoveryBuilder, PackageDiscoveryBuilder},
discovery::{LocalPackageDiscoveryBuilder, PackageDiscoveryBuilder},
package_graph::{PackageGraph, WorkspaceName},
package_json::PackageJson,
};
Expand All @@ -44,10 +44,7 @@ use crate::{
engine::{Engine, EngineBuilder},
opts::Opts,
process::ProcessManager,
run::{
global_hash::get_global_hash_inputs, package_discovery::DaemonPackageDiscovery,
summary::RunTracker,
},
run::{global_hash::get_global_hash_inputs, summary::RunTracker},
shim::TurboState,
signal::{SignalHandler, SignalSubscriber},
task_graph::Visitor,
Expand Down Expand Up @@ -195,7 +192,7 @@ impl<'a> Run<'a> {

let is_ci_or_not_tty = turborepo_ci::is_ci() || !std::io::stdout().is_terminal();

let mut daemon = if is_ci_or_not_tty && !opts.run_opts.no_daemon {
let daemon = if is_ci_or_not_tty && !opts.run_opts.no_daemon {
debug!("skipping turbod since we appear to be in a non-interactive context");
None
} else if !opts.run_opts.no_daemon {
Expand Down Expand Up @@ -224,18 +221,14 @@ impl<'a> Run<'a> {
let mut pkg_dep_graph =
PackageGraph::builder(&self.base.repo_root, root_package_json.clone())
.with_single_package_mode(opts.run_opts.single_package)
.with_package_discovery(FallbackPackageDiscovery::new(
daemon.as_mut().map(DaemonPackageDiscovery::new),
// TODO: we may never need this fallback, so we could make this a builder
// instead and instantiate it lazily
.with_package_discovery(
LocalPackageDiscoveryBuilder::new(
self.base.repo_root.clone(),
None,
Some(root_package_json.clone()),
)
.build()?,
Duration::from_millis(10),
))
)
.build()
.await?;

Expand Down
26 changes: 18 additions & 8 deletions crates/turborepo-repository/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! we can track areas of run that are performing sub-optimally.
use tokio_stream::{iter, StreamExt};
use tracing::debug;
use turbopath::AbsoluteSystemPathBuf;

use crate::{
Expand Down Expand Up @@ -190,14 +191,23 @@ impl<A: PackageDiscovery + Send, B: PackageDiscovery + Send> PackageDiscovery
{
async fn discover_packages(&mut self) -> Result<DiscoveryResponse, Error> {
match tokio::time::timeout(self.timeout, self.primary.discover_packages()).await {
Ok(Ok(packages)) => Ok(packages),
Ok(Err(err1)) => match self.fallback.discover_packages().await {
Ok(packages) => Ok(packages),
// if the backup is unavailable, return the original error
Err(Error::Unavailable) => Err(err1),
Err(err2) => Err(err2),
},
Err(_) => self.fallback.discover_packages().await,
Ok(Ok(packages)) => {
debug!("used primary strategy");
Ok(packages)
}
Ok(Err(err1)) => {
debug!("primary strategy failed. using fallback strategy");
match self.fallback.discover_packages().await {
Ok(packages) => Ok(packages),
// if the backup is unavailable, return the original error
Err(Error::Unavailable) => Err(err1),
Err(err2) => Err(err2),
}
}
Err(_) => {
debug!("primary strategy timed out. using fallback strategy");
self.fallback.discover_packages().await
}
}
}
}
Expand Down

1 comment on commit 7a18c96

@vercel
Copy link

@vercel vercel bot commented on 7a18c96 Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rust-docs – ./

turbo-xi.vercel.sh
rustdoc.turbo.build
rust-docs-git-main.vercel.sh
rust-docs.vercel.sh

Please sign in to comment.