diff --git a/apps/studio/src/index.ts b/apps/studio/src/index.ts index 04199f7e38..c3089c9d8c 100644 --- a/apps/studio/src/index.ts +++ b/apps/studio/src/index.ts @@ -24,6 +24,7 @@ import { } from 'electron-devtools-installer'; import { IPC_VOID_HANDLERS } from 'src/constants'; import * as ipcHandlers from 'src/ipc-handlers'; +import { markAppQuitting } from 'src/ipc-utils'; import { hasActiveSyncOperations, hasUploadingPushOperations, @@ -526,6 +527,7 @@ async function appBoot() { } ); app.on( 'will-quit', ( event ) => { + markAppQuitting(); globalShortcut.unregisterAll(); stopCliEventsSubscriber(); stopAllStudioCodeProcesses(); diff --git a/apps/studio/src/ipc-utils.ts b/apps/studio/src/ipc-utils.ts index 9d69f6962b..57472c5786 100644 --- a/apps/studio/src/ipc-utils.ts +++ b/apps/studio/src/ipc-utils.ts @@ -69,10 +69,19 @@ export interface IpcEvents { 'remote-session-status': [ RemoteSessionStatus ]; } +let isAppQuitting = false; + +export function markAppQuitting() { + isAppQuitting = true; +} + export async function sendIpcEventToRenderer< T extends keyof IpcEvents >( channel: T, ...args: IpcEvents[ T ] ): Promise< void > { + if ( isAppQuitting ) { + return; + } const window = await getMainWindow(); // `getMainWindow()` can resolve to `null` during early boot — e.g., the // daemon-status poller fires its initial tick before the renderer window