From 8d2fe8579ec092276279466d85831945d36028e4 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 19 May 2026 19:05:59 -0500 Subject: [PATCH] fix(desktop): handle missing autoUpdater on unsigned macOS builds electron-updater's autoUpdater is undefined when the app is not code-signed, causing a crash when clicking "Check for Updates". Guard all autoUpdater access with availability checks and surface a user-friendly error message instead. --- desktop/src/main/updater.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/desktop/src/main/updater.ts b/desktop/src/main/updater.ts index 3c0cf09be..17e79ad51 100644 --- a/desktop/src/main/updater.ts +++ b/desktop/src/main/updater.ts @@ -66,6 +66,11 @@ export async function initAutoUpdater( currentChannel = loadChannel() const { autoUpdater } = await import("electron-updater") + if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") { + console.warn("Auto-updater not available (app is not code-signed)") + return + } + autoUpdater.autoDownload = true autoUpdater.autoInstallOnAppQuit = true autoUpdater.allowPrerelease = currentChannel === "beta" @@ -137,6 +142,13 @@ export async function initAutoUpdater( export async function checkForUpdates(): Promise { const { autoUpdater } = await import("electron-updater") + if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") { + sendUpdateStatus({ + state: "error", + error: "Auto-update is not available (app is not code-signed)", + }) + return + } await autoUpdater.checkForUpdates() } @@ -146,6 +158,13 @@ export async function checkForUpdatesWithChannel( const { autoUpdater } = await import("electron-updater") currentChannel = channel saveChannel(channel) + if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") { + sendUpdateStatus({ + state: "error", + error: "Auto-update is not available (app is not code-signed)", + }) + return + } autoUpdater.allowPrerelease = channel === "beta" autoUpdater.channel = channel === "beta" ? "beta" : "latest" await autoUpdater.checkForUpdates() @@ -153,5 +172,8 @@ export async function checkForUpdatesWithChannel( export async function installUpdate(): Promise { const { autoUpdater } = await import("electron-updater") + if (!autoUpdater || typeof autoUpdater.quitAndInstall !== "function") { + return + } autoUpdater.quitAndInstall() }