-
-
Notifications
You must be signed in to change notification settings - Fork 104
Description
OS
Windows 11
Programming Language
Node.js/TypeScript (Electron)
VPK Version
NPM version - 0.0.1335-g2ad2c37 / CLI version: 0.0.1298
Library Version
Electron 35.2.1
What happened?
I called getUpdatePendingRestart() which is documented to return an UpdateInfo object, but it actually returns a VelopackAsset object instead. When I try to use this returned object with updateManager.waitExitThenApplyUpdate(updateInfo, true, true), the update process fails with a type mismatch error.
The documentation states that getUpdatePendingRestart() should return an UpdateInfo object containing TargetFullRelease, BaseRelease, DeltasToTarget, and IsDowngrade properties. However, the actual return value is a VelopackAsset object with properties like PackageId, Version, Type, FileName, etc.
When I pass this incorrectly typed object to waitExitThenApplyUpdate(), it fails because the method expects a proper UpdateInfo structure but receives a VelopackAsset object instead. This type inconsistency makes it impossible to properly apply pending updates in my Electron application.
My code:
const pendingUpdate = updateManager.getUpdatePendingRestart();
if (pendingUpdate) {
log.info('Update already downloaded and ready to install', pendingUpdate);
mainWindow.webContents.send(UPDATE_DOWNLOADED_CHANNEL, pendingUpdate);
return;
}
...
// Install update method
ipcMain.handle(UPDATE_INSTALL_CHANNEL, async (_, updateInfo: UpdateInfo) => {
if (!isUpdaterEnabled()) {
log.info('Update install requested but updater is disabled');
return;
}
log.info('Restarting app to apply update');
mainWindow.setClosable(true);
updateManager.waitExitThenApplyUpdate(updateInfo, true, true);
app.quit();
});Relevant log output
Update already downloaded and ready to install {"PackageId":"daktus-native","Version":"0.1.0","Type":"Full","FileName":"daktus-native-0.1.0-full.nupkg","SHA1":"a7b607bdeaf45e91b504ef3dbe9c4a2ce4d86a59","SHA256":"818a7414c1cb6b52e275e0c3be0a5e50d546f0e54a0800e77d9ac7c9ad9fbc84","Size":134707355,"NotesMarkdown":"","NotesHtml":""}
Restarting app to apply update
Error: invalid type: string "{\"PackageId\":\"daktus-native\",\"Version\":\"0.1.0\",\"Type\":\"Full\",\"FileName\":\"daktus-native-0.1.0-full.nupkg\",\"SHA1\":\"a7b607bdeaf45e91b504ef3dbe9c4a2ce4d86a59\",\"SHA256\":\"818a7414c1cb6b52e275e0c3be0a5e50d546f0e54a0800e77d9ac7c9ad9fbc84\",\"Size\":134707355,\"NotesMarkdown\":\"\",\"NotesHtml\":\"\"}", expected struct UpdateInfo at line 1 column 318