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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(recording): always kill port on restart, never reuse dying server
Louis Beaumont8c435a108c97
diff --git a/Cargo.toml b/Cargo.tomlindex 8877ef003..795a5a0d5 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri"]resolver = "2"[workspace.package]-version = "0.3.92"+version = "0.3.93"authors = ["louis030195 <[email protected]>"]description = ""repository = "https://github.com/screenpipe/screenpipe"diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 7b98ecb40..b7b1a24da 100755--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9007,7 +9007,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.0.293"+version = "2.0.298"dependencies = ["anyhow","async-stream",@@ -9089,7 +9089,7 @@ dependencies = [[[package]]name = "screenpipe-audio"-version = "0.3.87"+version = "0.3.92"dependencies = ["anyhow","bytemuck",@@ -9137,7 +9137,7 @@ dependencies = [[[package]]name = "screenpipe-core"-version = "0.3.87"+version = "0.3.92"dependencies = ["accessibility","accessibility-sys",@@ -9188,7 +9188,7 @@ dependencies = [[[package]]name = "screenpipe-db"-version = "0.3.87"+version = "0.3.92"dependencies = ["anyhow","chrono",@@ -9212,7 +9212,7 @@ dependencies = [[[package]]name = "screenpipe-events"-version = "0.3.87"+version = "0.3.92"dependencies = ["anyhow","chrono",@@ -9228,7 +9228,7 @@ dependencies = [[[package]]name = "screenpipe-integrations"-version = "0.3.87"+version = "0.3.92"dependencies = ["anyhow","image 0.25.9",@@ -9243,7 +9243,7 @@ dependencies = [[[package]]name = "screenpipe-server"-version = "0.3.87"+version = "0.3.92"dependencies = ["anyhow","async-trait",@@ -9307,7 +9307,7 @@ dependencies = [[[package]]name = "screenpipe-vision"-version = "0.3.87"+version = "0.3.92"dependencies = ["accessibility-sys","anyhow",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex de9d5ef53..4f47963a3 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.0.298"+version = "2.0.299"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs b/apps/screenpipe-app-tauri/src-tauri/src/recording.rsindex 73d4d99a5..97bc906f1 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/recording.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/recording.rs@@ -132,12 +132,11 @@ pub async fn spawn_screenpipe(let port = store.port;let health_url = format!("http://localhost:{}/health", port);- // Stop existing server if any, and decide whether to check for orphans- let need_orphan_check;+ // Check if we already own a running server{let mut handle_guard = state.0.lock().await;if handle_guard.is_some() {- // We own this server — check if it's healthy before restarting+ // We have a handle — check if it's still healthymatch reqwest::Client::new().get(&health_url).timeout(std::time::Duration::from_secs(2))@@ -157,33 +156,14 @@ pub async fn spawn_screenpipe(handle.shutdown();tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;}- need_orphan_check = false;- } else {- // No handle — cold start. Check if an orphaned process holds the port.- match reqwest::Client::new()- .get(&health_url)- .timeout(std::time::Duration::from_secs(2))- .send()- .await- {- Ok(resp) if resp.status().is_success() => {- // Orphan is healthy — reuse it- info!("Screenpipe server already running and healthy on port {} (no handle, reusing)", port);- return Ok(());- }- _ => {- // Port may be held by an unhealthy orphan- need_orphan_check = true;- }- }}}- // Kill any orphaned process holding our port (crash leftover, CLI run, etc.)- // Only needed on cold start — during intentional restart we already shut down above.- if need_orphan_check {- kill_process_on_port(port).await;- }+ // No handle — either cold start, or stop_screenpipe() already cleared it.+ // Kill whatever is on the port. We never "reuse" a handleless server because+ // it may be a dying process from stop_screenpipe() that hasn't released the+ // port yet. Always start fresh.+ kill_process_on_port(port).await;// Check permissions before startinglet permissions_check = do_permissions_check(false);