diff --git a/CHANGELOG.md b/CHANGELOG.md index 02777cda37..7a9e4c6a24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [unreleased] + +### Fixes + +* Fixed memory leak associated with autoUpdater ([#2606](https://github.com/TryQuiet/quiet/issues/2606)) + ## [2.3.1] ### Fixes diff --git a/packages/desktop/src/main/main.ts b/packages/desktop/src/main/main.ts index 340867b7d8..0617bc9e64 100644 --- a/packages/desktop/src/main/main.ts +++ b/packages/desktop/src/main/main.ts @@ -260,17 +260,19 @@ const isNetworkError = (errorObject: { message: string }) => { ) } -export const checkForUpdate = async (win: BrowserWindow) => { +export const checkForUpdate = async () => { try { await autoUpdater.checkForUpdates() } catch (error) { if (isNetworkError(error)) { - logger.error('Network Error') + logger.warn(`updater: ${error.message}`) } else { - logger.error('Unknown Error') - logger.error(error == null ? 'unknown' : (error.stack || error).toString()) + logger.error(error) } } +} + +const setupUpdater = async () => { autoUpdater.on('checking-for-update', () => { logger.info('updater: checking-for-update') }) @@ -285,7 +287,9 @@ export const checkForUpdate = async (win: BrowserWindow) => { }) autoUpdater.on('update-downloaded', () => { logger.info('updater: update-downloaded') - win.webContents.send('newUpdateAvailable') + if (isBrowserWindow(mainWindow)) { + mainWindow.webContents.send('newUpdateAvailable') + } }) autoUpdater.on('before-quit-for-update', () => { logger.info('updater: before-quit-for-update') @@ -505,12 +509,10 @@ app.on('ready', async () => { } } - await checkForUpdate(mainWindow) + await setupUpdater() + await checkForUpdate() setInterval(async () => { - if (!isBrowserWindow(mainWindow)) { - throw new Error(`mainWindow is on unexpected type ${mainWindow}`) - } - await checkForUpdate(mainWindow) + await checkForUpdate() }, updaterInterval) })