Skip to content

Commit 1e62db2

Browse files
chore(pro): slow down daemon startup attempts after reaching a max value of 10
1 parent ec2b0e6 commit 1e62db2

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

cmd/up.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ func (cmd *UpCmd) devPodUpProxy(
447447
return result, <-errChan
448448
}
449449

450-
// TODO: This is just re-using the proxy provider for now, need to change after runner refactoring
451450
func (cmd *UpCmd) devPodUpDaemon(
452451
ctx context.Context,
453452
client client2.DaemonClient,

desktop/src-tauri/src/resource_watcher.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,7 @@ impl Daemon {
287287
}
288288

289289
pub async fn try_start(&mut self, host: String, app_handle: &AppHandle) {
290-
if !self.should_retry() {
291-
self.try_notify_failed(app_handle);
292-
return;
293-
}
294-
info!(
295-
"[{}] attempting to start daemon ({}/10)",
296-
host, self.retry_count
297-
);
298-
self.retry_count += 1;
290+
info!("[{}] attempting to start daemon", host);
299291
if let Some(_) = self.command {
300292
self.try_stop().await;
301293
}
@@ -322,11 +314,20 @@ impl Daemon {
322314
self.status = daemon::DaemonStatus::default();
323315
}
324316

325-
fn should_retry(&self) -> bool {
317+
fn should_retry(&mut self, app_handle: &AppHandle) -> bool {
326318
if self.status.login_required {
327319
return false;
328320
}
329-
return self.retry_count <= MAX_RETRY_COUNT;
321+
322+
self.retry_count += 1;
323+
if self.retry_count < MAX_RETRY_COUNT {
324+
return true;
325+
} else {
326+
self.try_notify_failed(app_handle);
327+
328+
// fall back to every 5 ticks after reaching `MAX_RETRY_COUNT`
329+
return self.retry_count % 5 == 0;
330+
}
330331
}
331332

332333
fn should_debug(&self) -> bool {
@@ -489,7 +490,7 @@ async fn watch_daemons(app_handle: &AppHandle) -> anyhow::Result<()> {
489490
);
490491
}
491492
let daemon = instance.daemon.as_mut().unwrap();
492-
if !daemon.should_retry() {
493+
if !daemon.should_retry(app_handle) {
493494
all_ready = false;
494495
continue;
495496
}

0 commit comments

Comments
 (0)