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: 3 active bugs — char boundary panic, vision bail loop, IndexedDB noise

Louis Beaumont11c7439f1445
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsx
index 77230aa6a..1c9864767 100644
--- a/apps/screenpipe-app-tauri/app/layout.tsx
+++ b/apps/screenpipe-app-tauri/app/layout.tsx
@@ -47,13 +47,20 @@ export default function RootLayout({
}
} catch {}
- // Auto-reload on IndexedDB disconnect (APP-2E, 21 users)
+ // Auto-reload on IndexedDB disconnect (APP-2E, 27 users on v2.0.379)
// WKWebView's IndexedDB server can crash; the page becomes unusable.
+ // PostHog JS SDK uses IndexedDB for session replay — this is a known WebKit bug.
+ let idbReloadPending = false;
const handleUnhandledRejection = (e: PromiseRejectionEvent) => {
const msg = String(e.reason?.message || e.reason || "");
if (msg.includes("Connection to Indexed Database server lost")) {
- console.warn("IndexedDB server lost — reloading page");
- window.location.reload();
+ // Prevent the error from reaching Sentry — we handle it via reload
+ e.preventDefault();
+ if (idbReloadPending) return; // debounce: only one reload
+ idbReloadPending = true;
+ console.warn("IndexedDB server lost — reloading page in 1s");
+ // Short delay to let any in-flight operations settle
+ setTimeout(() => window.location.reload(), 1000);
}
};
window.addEventListener("unhandledrejection", handleUnhandledRejection);
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 6f6bbe284..d0bb781a7 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -8719,7 +8719,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.379"
+version = "2.0.380"
dependencies = [
"anyhow",
"async-stream",
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index be14b76f6..2f41b1922 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -943,6 +943,16 @@ async fn main() {
if let Some(ref mut msg) = event.message {
*msg = strip_user_paths(msg);
}
+ // Filter out IndexedDB disconnect errors (APP-2E)
+ // WKWebView's IndexedDB server crashes are handled via auto-reload
+ // in layout.tsx — no need to report to Sentry
+ for val in event.exception.values.iter() {
+ if let Some(ref v) = val.value {
+ if v.contains("Indexed Database server lost") {
+ return None;
+ }
+ }
+ }
for val in event.exception.values.iter_mut() {
if let Some(ref mut v) = val.value {
*v = strip_user_paths(v);
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/reminders.rs b/apps/screenpipe-app-tauri/src-tauri/src/reminders.rs
index 0d08805ab..4a8c14ed2 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/reminders.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/reminders.rs
@@ -646,7 +646,11 @@ async fn call_ai_for_reminders(
) -> Result<String, String> {
// Truncate to fit context window (~10K chars max)
let context = if context.len() > 6000 {
- &context[..6000]
+ let mut end = 6000;
+ while !context.is_char_boundary(end) {
+ end -= 1;
+ }
+ &context[..end]
} else {
context
};
@@ -759,7 +763,11 @@ pub(crate) fn parse_action_items(response: &str) -> Vec<ActionItemParsed> {
warn!(
"reminders: failed to parse AI response: {} | raw: {}",
e,
- &response[..response.len().min(200)]
+ {
+ let mut end = response.len().min(200);
+ while !response.is_char_boundary(end) { end -= 1; }
+ &response[..end]
+ }
);
Vec::new()
}
diff --git a/crates/screenpipe-server/src/vision_manager/manager.rs b/crates/screenpipe-server/src/vision_manager/manager.rs
index f19ec57a2..107efb9fc 100644
--- a/crates/screenpipe-server/src/vision_manager/manager.rs
+++ b/crates/screenpipe-server/src/vision_manager/manager.rs
@@ -170,6 +170,7 @@ impl VisionManager {
// Spawn the recording task using the existing record_video function
let handle = self.vision_handle.spawn(async move {
+ let mut consecutive_restarts: u32 = 0;
loop {
match record_video(
db.clone(),
@@ -195,11 +196,33 @@ impl VisionManager {
break;
}
Err(e) => {
+ consecutive_restarts += 1;
+
+ // Before restarting, verify the monitor still exists
+ let monitor_exists = get_monitor_by_id(monitor_id).await.is_some();
+
+ if !monitor_exists {
+ warn!(
+ "Monitor {} no longer exists after error: {:?}. \
+ Stopping task — MonitorWatcher will restart if it reappears.",
+ monitor_id, e
+ );
+ break;
+ }
+
+ // Exponential backoff: 1s, 2s, 4s, 8s, 16s, capped at 30s
+ let backoff =
+ Duration::from_secs((1u64 << consecutive_restarts.min(4)).min(30));
error!(
- "Monitor {} recording error: {:?}, restarting in 1s...",
- monitor_id, e
+ "Monitor {} recording error (restart #{}): {:?}, retrying in {:?}",
+ monitor_id, consecutive_restarts, e, backoff
);
- tokio::time::sleep(Duration::from_secs(1)).await;
+ tokio::time::sleep(backoff).await;
+
+ // Reset restart counter after successful long run (>5 min)
+ // This is handled implicitly: if record_video runs for a while
+ // and then fails, the backoff is appropriate. If it fails immediately
+ // (capture broken), backoff grows quickly to stop hammering.
}
}
}