Skip to content

Commit

Permalink
Merge branch 'develop' into update-orbitdb
Browse files Browse the repository at this point in the history
  • Loading branch information
islathehut committed Oct 24, 2024
2 parents 7a9a1c3 + 2f1f448 commit b391aec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 12 additions & 10 deletions packages/desktop/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand All @@ -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')
Expand Down Expand Up @@ -514,12 +518,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)
})

Expand Down

0 comments on commit b391aec

Please sign in to comment.