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
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
"core:window:allow-toggle-maximize",
|
"core:window:allow-toggle-maximize",
|
||||||
"core:window:allow-unminimize",
|
"core:window:allow-unminimize",
|
||||||
"core:window:allow-close",
|
"core:window:allow-close",
|
||||||
|
"core:window:allow-destroy",
|
||||||
"core:window:allow-is-maximized",
|
"core:window:allow-is-maximized",
|
||||||
"core:window:allow-start-dragging",
|
"core:window:allow-start-dragging",
|
||||||
"dialog:allow-open",
|
"dialog:allow-open",
|
||||||
|
|||||||
@@ -48,7 +48,12 @@ function randomHex(bytes: number): string {
|
|||||||
|
|
||||||
export async function tracedInvoke<T>(command: string, args?: Record<string, unknown>): Promise<T> {
|
export async function tracedInvoke<T>(command: string, args?: Record<string, unknown>): Promise<T> {
|
||||||
if (frontendShuttingDown) {
|
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<T>(() => {});
|
||||||
}
|
}
|
||||||
if (!telemetryEnabled) return invoke<T>(command, args);
|
if (!telemetryEnabled) return invoke<T>(command, args);
|
||||||
const startedAtMs = Date.now();
|
const startedAtMs = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user