Skip to content

Commit

Permalink
fix(Turborepo): Flag off daemon for package discovery (#7290)
Browse files Browse the repository at this point in the history
### Description

Daemon package watching has some bugs that need to be ironed out. Flag
it off for now.

### Testing Instructions

Disabled integration test that explicitly checks for the behavior that
we are flagging off.

Closes TURBO-2265

---------

Co-authored-by: Greg Soltis <Greg Soltis>
Co-authored-by: Chris Olszewski <[email protected]>
  • Loading branch information
Greg Soltis and chris-olszewski authored Feb 6, 2024
1 parent 4fe5a9d commit e834b54
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
1 change: 1 addition & 0 deletions crates/turborepo-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rustls-tls = ["turborepo-api-client/rustls-tls", "turbo-updater/rustls-tls"]
http = ["tonic-reflection"]

go-daemon = []
daemon-package-discovery = []

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dev-dependencies]
Expand Down
53 changes: 30 additions & 23 deletions crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ impl Run {
let is_ci_or_not_tty = turborepo_ci::is_ci() || !std::io::stdout().is_terminal();
run_telemetry.track_ci(turborepo_ci::Vendor::get_name());

// Remove allow when daemon is flagged back on
#[allow(unused_mut)]
let mut daemon = match (is_ci_or_not_tty, self.opts.run_opts.daemon) {
(true, None) => {
run_telemetry.track_daemon_init(DaemonInitStatus::Skipped);
Expand Down Expand Up @@ -272,33 +274,38 @@ impl Run {
}
};

// if we are forcing the daemon, we don't want to fallback to local discovery
let (fallback, duration) = if let Some(true) = self.opts.run_opts.daemon {
(None, Duration::MAX)
} else {
(
Some(
LocalPackageDiscoveryBuilder::new(
self.base.repo_root.clone(),
None,
Some(root_package_json.clone()),
let mut pkg_dep_graph = {
let builder = PackageGraph::builder(&self.base.repo_root, root_package_json.clone())
.with_single_package_mode(self.opts.run_opts.single_package);

#[cfg(feature = "daemon-package-discovery")]
let builder = {
// if we are forcing the daemon, we don't want to fallback to local discovery
let (fallback, duration) = if let Some(true) = self.opts.run_opts.daemon {
(None, Duration::MAX)
} else {
(
Some(
LocalPackageDiscoveryBuilder::new(
self.base.repo_root.clone(),
None,
Some(root_package_json.clone()),
)
.build()?,
),
Duration::from_millis(10),
)
.build()?,
),
Duration::from_millis(10),
)
};

let mut pkg_dep_graph =
PackageGraph::builder(&self.base.repo_root, root_package_json.clone())
.with_single_package_mode(self.opts.run_opts.single_package)
.with_package_discovery(FallbackPackageDiscovery::new(
};
let fallback_discovery = FallbackPackageDiscovery::new(
daemon.as_mut().map(DaemonPackageDiscovery::new),
fallback,
duration,
))
.build()
.await?;
);
builder.with_package_discovery(fallback_discovery)
};

builder.build().await?
};

repo_telemetry.track_package_manager(pkg_dep_graph.package_manager().to_string());
repo_telemetry.track_size(pkg_dep_graph.len());
Expand Down

0 comments on commit e834b54

Please sign in to comment.