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: Windows crash on startup — Instant overflow when uptime < 1 hour

Louis Beaumont7c52032a192f
diff --git a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
index ef962065d..45fb85d8b 100644
--- a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
+++ b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
@@ -51,8 +51,10 @@ impl OutputRecoveryBackoff {
Self {
attempts: 0,
is_permanent: false,
- // Set to epoch-ish so the first check always fires
- last_attempt: Instant::now() - Duration::from_secs(3600),
+ // Set to epoch-ish so the first check always fires.
+ // Use checked_sub to avoid panic on Windows when uptime < 3600s
+ // (Instant - Duration panics if result would be before boot time).
+ last_attempt: Instant::now().checked_sub(Duration::from_secs(3600)).unwrap_or(Instant::now()),
}
}
diff --git a/crates/screenpipe-screen/src/core.rs b/crates/screenpipe-screen/src/core.rs
index 8f13bf4a2..317043927 100644
--- a/crates/screenpipe-screen/src/core.rs
+++ b/crates/screenpipe-screen/src/core.rs
@@ -103,7 +103,8 @@ where
D: Deserializer<'de>,
{
let millis: u128 = Deserialize::deserialize(deserializer)?;
- Ok(Instant::now() - Duration::from_millis(millis as u64))
+ let dur = Duration::from_millis(millis as u64);
+ Ok(Instant::now().checked_sub(dur).unwrap_or(Instant::now()))
}
pub struct CaptureResult {