From 12ec92603244c3437d136e9471066b72e05d6ccd Mon Sep 17 00:00:00 2001 From: Ivan Ottinger <25105483+ivan-ottinger@users.noreply.github.com> Date: Mon, 25 May 2026 13:19:45 +0200 Subject: [PATCH] Prevent ghost windows when quitting during site startup --- apps/studio/src/index.ts | 2 ++ apps/studio/src/ipc-utils.ts | 9 +++++++++ 2 files changed, 11 insertions(+) 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