From 524f8ff2776fa70c721c960cad3ece28b84c5ef2 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 8 Jun 2025 21:39:56 +0200 Subject: [PATCH] ipcCommands: check if mainWin is alive --- src/main/ipcCommands.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/ipcCommands.ts b/src/main/ipcCommands.ts index 51332b4..8731b8d 100644 --- a/src/main/ipcCommands.ts +++ b/src/main/ipcCommands.ts @@ -31,6 +31,11 @@ export interface IpcResponse { * You must add a handler for the message in the renderer process. */ export function sendRendererCommand(message: string, data?: any) { + if (mainWin.isDestroyed()) { + console.warn("Main window is destroyed, cannot send IPC command:", message); + return Promise.reject(new Error("Main window is destroyed")); + } + const nonce = randomUUID(); const promise = new Promise((resolve, reject) => {