diff --git a/packages/app/src/runtime/host-runtime.ts b/packages/app/src/runtime/host-runtime.ts index c228273bd..237a246e1 100644 --- a/packages/app/src/runtime/host-runtime.ts +++ b/packages/app/src/runtime/host-runtime.ts @@ -1162,19 +1162,34 @@ export class HostRuntimeStore { } private async bootstrapDesktop(): Promise { - try { - const daemon = await startDesktopDaemon(); - const connection = connectionFromListen(daemon.listen); - if (!connection || !daemon.serverId) { + let lastError: unknown = null; + + for (let attempt = 1; attempt <= 3; attempt += 1) { + try { + const daemon = await startDesktopDaemon(); + const connection = connectionFromListen(daemon.listen); + if (!connection || !daemon.serverId) { + return; + } + await this.upsertHostConnection({ + serverId: daemon.serverId, + label: daemon.hostname ?? undefined, + connection, + }); return; + } catch (error) { + lastError = error; + console.warn(`[HostRuntime] Failed to bootstrap desktop daemon (attempt ${attempt}/3)`, error); + if (attempt < 3) { + await new Promise((resolve) => { + setTimeout(resolve, attempt * 500); + }); + } } - await this.upsertHostConnection({ - serverId: daemon.serverId, - label: daemon.hostname ?? undefined, - connection, - }); - } catch (error) { - console.warn("[HostRuntime] Failed to bootstrap desktop daemon", error); + } + + if (lastError) { + console.warn("[HostRuntime] Desktop daemon bootstrap exhausted retries", lastError); } } diff --git a/packages/desktop/src/main.ts b/packages/desktop/src/main.ts index 1579045fd..e0a476968 100644 --- a/packages/desktop/src/main.ts +++ b/packages/desktop/src/main.ts @@ -1,5 +1,5 @@ import log from "electron-log/main"; -log.initialize(); +log.initialize({ spyRendererConsole: true }); import path from "node:path"; import { pathToFileURL } from "node:url";