diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index 2647e64..b0a724d 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -13,12 +13,6 @@ let isQuitting = false const shouldAbortWindowLoad = (): boolean => isQuitting || !mainWindow || mainWindow.isDestroyed() -const logLifecycle = (message: string) => { - if (!app.isPackaged) { - console.log(message) - } -} - const getAvailablePort = (): Promise => new Promise((resolve, reject) => { const server = createServer() @@ -99,7 +93,7 @@ const spawnServer = (port: number): string => { return `http://127.0.0.1:${port}` } -const getServerUrl = async (): Promise => { +const resolveServerUrl = async (): Promise => { if (!app.isPackaged) { return DEV_SERVER_URL } @@ -140,13 +134,13 @@ const createWindow = async () => { } mainWindow.show() - const serverUrl = await getServerUrl() + const serverUrl = await resolveServerUrl() if (!serverUrl || shouldAbortWindowLoad()) { stopServerProcess() return } - logLifecycle(`Waiting for server at ${serverUrl}...`) + if (!app.isPackaged) console.log(`Waiting for server at ${serverUrl}...`) const ready = await waitForServer(serverUrl) if (shouldAbortWindowLoad()) { stopServerProcess() @@ -163,10 +157,6 @@ const createWindow = async () => { return } - logLifecycle(`Loading ${serverUrl}`) - if (shouldAbortWindowLoad()) { - return - } mainWindow.loadURL(serverUrl) } @@ -175,7 +165,13 @@ const beginQuit = () => { stopServerProcess() } -app.whenReady().then(createWindow) +app + .whenReady() + .then(createWindow) + .catch((e) => { + console.error('Failed to create window:', e) + app.quit() + }) app.on('window-all-closed', () => { if (process.platform !== 'darwin') {