Skip to content

Commit 1e667e2

Browse files
authored
fix: Move version check back into a thread. (#668)
* Place back in a thread. * Update changelog.
1 parent 6f25e1a commit 1e667e2

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

crates/cli/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ pub async fn run_cli() {
8484
setup_logging(&args.log, args.log_file);
8585
setup_caching(&args.cache);
8686

87+
let version_check = tokio::spawn(check_version(env!("CARGO_PKG_VERSION")));
88+
8789
// Match and run subcommand
8890
let result = match args.command {
8991
Commands::Bin { tool } => bin(tool).await,
@@ -287,14 +289,14 @@ pub async fn run_cli() {
287289

288290
// Defer checking for a new version as it requires the workspace root
289291
// to exist. Otherwise, the `init` command would panic while checking!
290-
match check_version(env!("CARGO_PKG_VERSION")).await {
291-
Ok((newer_version, true)) => {
292+
match version_check.await {
293+
Ok(Ok((newer_version, true))) => {
292294
println!(
293295
"There's a new version of moon! {newer_version}\n\
294296
Run `moon upgrade` or install from https://moonrepo.dev/docs/install",
295297
);
296298
}
297-
Err(error) => {
299+
Ok(Err(error)) => {
298300
debug!(target: "moon:cli", "Failed to check for current version: {}", error);
299301
}
300302
_ => {}

crates/core/launchpad/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::time::{Duration, SystemTime};
1212
use uuid::Uuid;
1313

1414
const CURRENT_VERSION_URL: &str = "https://launch.moonrepo.app/versions/cli/current";
15-
const ALERT_PAUSE_DURATION: Duration = Duration::from_secs(28800); // 8 hours
15+
const ALERT_PAUSE_DURATION: Duration = Duration::from_secs(43200); // 12 hours
1616

1717
#[derive(Debug, Deserialize, Serialize)]
1818
pub struct CurrentVersion {
@@ -63,7 +63,7 @@ pub async fn check_version(
6363
let check_state_path = moon_dir.join("cache/states/versionCheck.json");
6464
let now = SystemTime::now();
6565

66-
// Only check once every 8 hours
66+
// Only check once every 12 hours
6767
if let Ok(file) = fs::read(&check_state_path) {
6868
let check_state: Result<CheckState, _> = serde_json::from_str(&file);
6969

packages/cli/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Fixed an issue where workspace relative `outputs` were not being included in the hashed tarball.
88

9+
#### ⚙️ Internal
10+
11+
- Reduced new version check to once every 12 hours.
12+
913
## 0.25.2
1014

1115
#### 🐞 Fixes

0 commit comments

Comments
 (0)