diff --git a/main/helpers.ts b/main/helpers.ts index 25516db6..bb3913ab 100644 --- a/main/helpers.ts +++ b/main/helpers.ts @@ -73,3 +73,17 @@ export async function getErrorHandledReponse(func: () => Promise) { export function rendererLog(main: Main, ...args: unknown[]) { main.mainWindow?.webContents.send(IPC_CHANNELS.CONSOLE_LOG, ...args); } + +export function isNetworkError(error: Error) { + switch (error?.message) { + case 'net::ERR_INTERNET_DISCONNECTED': + case 'net::ERR_PROXY_CONNECTION_FAILED': + case 'net::ERR_CONNECTION_RESET': + case 'net::ERR_CONNECTION_CLOSE': + case 'net::ERR_NAME_NOT_RESOLVED': + case 'net::ERR_CONNECTION_TIMED_OUT': + return true; + default: + return false; + } +} diff --git a/main/registerAutoUpdaterListeners.ts b/main/registerAutoUpdaterListeners.ts index ef858ecf..b712777c 100644 --- a/main/registerAutoUpdaterListeners.ts +++ b/main/registerAutoUpdaterListeners.ts @@ -2,14 +2,19 @@ import { emitMainProcessError } from 'backend/helpers'; import { app, dialog } from 'electron'; import { autoUpdater, UpdateInfo } from 'electron-updater'; import { Main } from '../main'; +import { isNetworkError } from './helpers'; export default function registerAutoUpdaterListeners(main: Main) { autoUpdater.autoDownload = false; + autoUpdater.allowPrerelease = true; autoUpdater.autoInstallOnAppQuit = true; autoUpdater.on('error', (error) => { if (!main.checkedForUpdate) { main.checkedForUpdate = true; + } + + if (isNetworkError(error)) { return; } diff --git a/main/registerIpcMainActionListeners.ts b/main/registerIpcMainActionListeners.ts index 8205e191..66e7a16c 100644 --- a/main/registerIpcMainActionListeners.ts +++ b/main/registerIpcMainActionListeners.ts @@ -12,7 +12,8 @@ import { getLanguageMap } from './getLanguageMap'; import { getConfigFilesWithModified, getErrorHandledReponse, - setAndGetCleanedConfigFiles, + isNetworkError, + setAndGetCleanedConfigFiles } from './helpers'; import { saveHtmlAsPdf } from './saveHtmlAsPdf'; @@ -60,6 +61,10 @@ export default function registerIpcMainActionListeners(main: Main) { try { await autoUpdater.checkForUpdates(); } catch (error) { + if (isNetworkError(error as Error)) { + return; + } + emitMainProcessError(error); } main.checkedForUpdate = true;