From f621638eb3d6bad363e95233b52b4d418c3798e1 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Thu, 13 Aug 2026 22:11:45 +0200 Subject: [PATCH] feat(system): enable window destroy capability and stabilize shutdown Adds a new window capability to allow destroying the window. It also changes shutdown handling in telemetry to avoid errors. - Add core:window:allow-destroy to default capabilities - Avoid shutdown errors by returning a pending promise in tracedInvoke - Improve stability during shutdown for in-flight telemetry calls --- src-tauri/capabilities/default.json | 1 + src/lib/telemetry.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index d2b1ecb..54bab96 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -9,6 +9,7 @@ "core:window:allow-toggle-maximize", "core:window:allow-unminimize", "core:window:allow-close", + "core:window:allow-destroy", "core:window:allow-is-maximized", "core:window:allow-start-dragging", "dialog:allow-open", diff --git a/src/lib/telemetry.ts b/src/lib/telemetry.ts index 9880dd5..08222c5 100644 --- a/src/lib/telemetry.ts +++ b/src/lib/telemetry.ts @@ -48,7 +48,12 @@ function randomHex(bytes: number): string { export async function tracedInvoke(command: string, args?: Record): Promise { if (frontendShuttingDown) { - throw new Error("Application is shutting down"); + // The window is on its way out and nothing calls preventDefault() on the + // close event, so it will finish closing regardless. Never resolving + // avoids surfacing a spurious "shutting down" error in whatever UI catch + // block happens to be awaiting an in-flight operation (e.g. a pull/push + // that makes several sequential calls) when the close request lands. + return new Promise(() => {}); } if (!telemetryEnabled) return invoke(command, args); const startedAtMs = Date.now();