Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/studio/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -526,6 +527,7 @@ async function appBoot() {
} );

app.on( 'will-quit', ( event ) => {
markAppQuitting();
globalShortcut.unregisterAll();
stopCliEventsSubscriber();
stopAllStudioCodeProcesses();
Expand Down
9 changes: 9 additions & 0 deletions apps/studio/src/ipc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down