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) => {