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: detect DB write stalls and show restart notification

Louis Beaumont1b4bf791839b
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/health.rs b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
index 8db88a039..fd8bf42b2 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/health.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
@@ -138,6 +138,12 @@ struct HealthCheckResponse {
/// Audio pipeline metrics for stall detection
#[serde(default)]
audio_pipeline: Option<AudioPipelineInfo>,
+ /// Vision capture alive but DB writes stopped (pool exhaustion)
+ #[serde(default)]
+ vision_db_write_stalled: bool,
+ /// Audio devices active but DB writes stopped (pool exhaustion)
+ #[serde(default)]
+ audio_db_write_stalled: bool,
}
/// Decide recording status based on health check result and time since startup.
@@ -458,8 +464,9 @@ pub async fn start_health_check(app: tauri::AppHandle) -> Result<()> {
})
.unwrap_or(false);
- // Audio stall tracking
- if audio_bad && !audio_excused {
+ // Audio stall tracking — also trigger on DB write stalls
+ let audio_db_stalled = health.audio_db_write_stalled;
+ if (audio_bad || audio_db_stalled) && !audio_excused {
consecutive_audio_stall = consecutive_audio_stall.saturating_add(1);
} else {
if consecutive_audio_stall >= CAPTURE_STALL_THRESHOLD {
@@ -468,8 +475,10 @@ pub async fn start_health_check(app: tauri::AppHandle) -> Result<()> {
consecutive_audio_stall = 0;
}
- // Vision stall tracking
- if vision_bad {
+ // Vision stall tracking — also trigger on DB write stalls
+ // (capture loop alive but pool exhaustion blocking writes)
+ let vision_db_stalled = health.vision_db_write_stalled;
+ if vision_bad || vision_db_stalled {
consecutive_vision_stall = consecutive_vision_stall.saturating_add(1);
} else {
if consecutive_vision_stall >= CAPTURE_STALL_THRESHOLD {
@@ -516,9 +525,10 @@ pub async fn start_health_check(app: tauri::AppHandle) -> Result<()> {
.map(|t| now_instant.duration_since(t) >= NOTIFICATION_COOLDOWN)
.unwrap_or(true);
if cooldown_ok {
+ let reason = if vision_db_stalled { "db write stall" } else { "capture stall" };
warn!(
- "vision capture stalled for {}s, showing restart notification",
- CAPTURE_STALL_THRESHOLD
+ "vision {} for {}s, showing restart notification",
+ reason, CAPTURE_STALL_THRESHOLD
);
last_vision_notification = Some(now_instant);
let _ = show_capture_stall_notification(&app, "screen").await;
diff --git a/crates/screenpipe-engine/src/routes/health.rs b/crates/screenpipe-engine/src/routes/health.rs
index 84c79653d..65be708eb 100644
--- a/crates/screenpipe-engine/src/routes/health.rs
+++ b/crates/screenpipe-engine/src/routes/health.rs
@@ -55,6 +55,12 @@ pub struct HealthCheckResponse {
pub accessibility: Option<TreeWalkerSnapshot>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pool_stats: Option<PoolHealthInfo>,
+ /// True when vision capture loop is alive but DB writes have stopped (pool exhaustion).
+ #[serde(default)]
+ pub vision_db_write_stalled: bool,
+ /// True when audio devices are active but DB writes have stopped (pool exhaustion).
+ #[serde(default)]
+ pub audio_db_write_stalled: bool,
}
#[derive(Serialize, OaSchema, Deserialize)]
@@ -590,6 +596,8 @@ pub async fn health_check(State(state): State<Arc<AppState>>) -> JsonResponse<He
write_pool_idle: wi,
})
},
+ vision_db_write_stalled,
+ audio_db_write_stalled,
})
}