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: patch Tauri event listener race condition (APP-2/5/9/W, 69 users)

Louis Beaumontcc09de616363
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsx
index b34e40073..d3563e230 100644
--- a/apps/screenpipe-app-tauri/app/layout.tsx
+++ b/apps/screenpipe-app-tauri/app/layout.tsx
@@ -30,6 +30,23 @@ export default function RootLayout({
useEffect(() => {
if (typeof window === "undefined") return;
+ // Patch Tauri event listener race condition (APP-2/5/9/W, 69 users)
+ // Tauri's unregisterListener doesn't null-check listeners[eventId]
+ // causing TypeError when unlisten is called on already-removed listener
+ try {
+ const internals = (window as any).__TAURI_EVENT_PLUGIN_INTERNALS__;
+ if (internals?.unregisterListener) {
+ const original = internals.unregisterListener;
+ internals.unregisterListener = function(event: string, eventId: number) {
+ try {
+ return original(event, eventId);
+ } catch {
+ // listener already removed — race condition, ignore
+ }
+ };
+ }
+ } catch {}
+
const logs: string[] = [];
const MAX_LOGS = 1000;
const originalConsole = { ...console };