After updating the libraries I am unable to update my app from a generic provider. Electron locates the update on GitHub, but stops thereafter with the following message:
21:26.389] [info] App starting...
:
1:28.518] [info] controllando se ci sono aggiomnamenti..
28.518] [info] Checking for update
21
30.1561 (info] Found vereion 2.1.7 (url: ------2.1.7-mac.zip, I -2.1.7.dng)
21:32.0331 [error] Error: TypeError: Cannot read properties of undefined (reading 'setclosable')
at MacUpdater.<anonymous> /Applications/.app/Contents/Resources/app.asar/updater.js:88:7)
at MacUpdater.emit (nodetevents:513:28)
at MacUpdater.onUpdateAvailable (/Applications/.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:337:14)
at MacUpdater.docheekForUpdates (/Applications/.app/Contents/Resources/app.asar/node modules/electron-updater/out/AppUpdater.js:323:14]
at procese.processTicksAndRejections (nodesinternal/process/task_queues:95:5)
11:21:32.0341 [info] errore durante 9li aggiornamenti.:
[node:15065) UnhendledPromiseReiection₩arning: TypeError: Cannot read properties of undefined (reading 'webContents')
at diepatch (/Applicetions/_app/Contents/Resources/app.asax/updater.js:23:7)
at MacUpdater.<anonymous> (/Applications/.app/Contents/Resources/app.asax/updater.js:94:3)
at MacUpdater.emit (nodetevente:526:35)
at /Applications/ app/Contents/Resources/app.asax/node_modules/electzon-updater/out/AppUpdater.js:196:18
at procese.processTickeAndRejections (nodesinternal/process/task,queues:95:5)
(Use `Laore =-trace-worninge` to show where the warning was created)
(node:16065) UnhandledPromiseRejectionMorning: Unhandled promise rejection. This exror originated either by throwing inside of an async function without a catch block, or by zejecting 0 Promiee which was not handled with .catchf). To terminate the node process on unhandled promise rejection, use the CLI flag "-unhandled-rejectiong=strict' (see httpe://nodejs.org/opi/cli.html#cli_ unhandled_ rejections_mode). (rejection id: 1)
As follow the libraries versions:
- electron": "^23.1.2",
- electron-builder": "^23.6.0",
- electron-packager": "^13.1.1",
- electron-reload": "^1.4.0",
- electron-updater": "^5.0.0",
- electron-winstaller": "^3.0.4",
- standard": "^17.0.0"
updater.js
const electron = require('electron')
const path = require('path')
const {app, dialog, BrowserWindow, ipcMain} = electron
const log = require('electron-log')
const {autoUpdater} = require('electron-updater')
let win;
autoUpdater.autoDownload = false
autoUpdater.logger = log
autoUpdater.logger.transports.file.level = 'info'
autoUpdater.setFeedURL({
provider: 'github',
token: '',
owner: '',
repo: '',
vPrefixedTagName: true,
private: true
})
const dispatch = (data) => {
win.webContents.send('message', data)
}
const createDefaultWindow = () => {
win = new BrowserWindow({
icon: path.join(__dirname, '/resources/icons/logo.png'),
width:600,
height: 300
})
win.on('closed', () => {
win = null
})
win.setMenu(null);
win.setClosable(false);
win.loadFile('electronMessage/index.html')
return win
}
app.on('ready', () => {
log.info('controllando se ci sono aggiornamenti..')
autoUpdater.checkForUpdates()
})
app.on('window-all-closed', () => {
app.quit()
})
autoUpdater.on('update-available', (info) => {
dialog.showMessageBox({
type: 'info',
title: 'Sono disponibili nuovi aggiornamenti',
message: 'L\'applicazione verrà aggiornata in automatico.',
buttons: ['Ok']
}, (buttonIndex) => {
if (buttonIndex === 0) {
createDefaultWindow()
win.webContents.on('did-finish-load', () => {
win.webContents.send('version', app.getVersion())
})
autoUpdater.downloadUpdate()
}
})
win.setClosable(false);
})
autoUpdater.on('error', (err) => {
log.info('errore durante gli aggiornamenti..')
dispatch('Si è verificato un errore durante il download degli aggiornamenti: ' + err);
win.setClosable(true);
})
autoUpdater.on('download-progress', (progressObj) => {
let log_message ='';
log_message = log_message + "Velocita\' scaricamento: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Scaricati ' + progressObj.transferred + " di " + progressObj.total + '\n';
let infoLoad = Math.round(progressObj.percent) + '%';
win.webContents.send('info-speed', log_message)
win.webContents.send('info-load', infoLoad)
win.webContents.send('download-progress', progressObj.percent)
win.setProgressBar(progressObj.percent);
})
autoUpdater.on('update-downloaded', (info) => {
log.info('aggiornamenti scaricati..')
win.setClosable(true);
win.close();
dialog.showMessageBox({
type: 'info',
title: 'Installazione',
message: 'Aggiornamenti scaricati, l\'applicazione verrà riavviata...',
buttons: ['Ok']
}, (buttonIndex) => {
if (buttonIndex === 0) {
setImmediate(() => {
app.removeAllListeners("window-all-closed")
autoUpdater.quitAndInstall(false)
})
}
})
})