Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(enterprise/sync): don't exit task when Sender is dropped

Louis Beaumont9ef9535d3e5e
diff --git a/ee/desktop-rust/enterprise_sync.rs b/ee/desktop-rust/enterprise_sync.rs
index 97458556a..be9f1db2d 100644
--- a/ee/desktop-rust/enterprise_sync.rs
+++ b/ee/desktop-rust/enterprise_sync.rs
@@ -464,6 +464,13 @@ pub async fn run(
/// Sleep for `dur` or return early when shutdown fires. Returns true if
/// shutdown was signalled (caller should break).
+///
+/// `Sender` dropped (= channel closed) is intentionally **not** treated as a
+/// shutdown signal: in the desktop wiring the spawn site doesn't keep the
+/// `Sender` around (there's no graceful-shutdown protocol — tauri just SIGKILLs
+/// the process on quit), so the channel closes immediately after spawn. If
+/// we honored that as shutdown, the task would exit after one tick. We only
+/// break on an explicit `Sender::send(true)` from a test.
async fn sleep_or_shutdown(
dur: Duration,
shutdown: &mut tokio::sync::watch::Receiver<bool>,
@@ -471,8 +478,8 @@ async fn sleep_or_shutdown(
tokio::select! {
_ = tokio::time::sleep(dur) => false,
changed = shutdown.changed() => {
- // Either Ok(()) with new value or Err (channel closed).
- changed.is_err() || *shutdown.borrow()
+ // Sender dropped → keep running. Explicit `true` value → shutdown.
+ changed.is_ok() && *shutdown.borrow()
}
}
}