electron-builder: Fail to install update because of app process running (Windows)
- Electron-Builder Version: ^23.6.0
- Electron-Updater Version: ^5.3.0
- Node Version: 16.x
- Electron Version: ^23.0.0
- Electron Type (current, beta, nightly):
- Target: Windows (nsis)
I’m having an issue with WIndows when trying to install the update.
The problem is that after quitting the app, there’s a process “hanging” that is not closed after quitting the app, which gives the user an error when trying to update the app.
I know that this issue is not on electron-updater side, but I’m wondering if there’s anything I can do to force electron-updater to close any running process of my application, because this process that doesn’t quit is a bug under investigation in another library, and it doesn’t seem like they will fix it quickly.
Examples:
When I run .quitAndInstall(), the UI will show to the user that the application is running and he needs to close, and it won’t work unless the user go to task manager and close the running process.
autoUpdater.on('update-downloaded', (info) => {
sendStatusToWindow(ChannelsTypes.UPDATE_DOWNLOADED, info.version);
setTimeout(() => autoUpdater.quitAndInstall(), 500);
});
I also tried adding isSilent and isForceRunAfter to true, but what happens is that the app closes to install in silent mode, but it doesn’t open again (probably because it failed to install), but since it’s on silent mode, it won’t show any errors to the user.
autoUpdater.on('update-downloaded', (info) => {
sendStatusToWindow(ChannelsTypes.UPDATE_DOWNLOADED, info.version);
setTimeout(() => autoUpdater.quitAndInstall(true, true), 500);
});
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (2 by maintainers)
I’m not very familiar with it either, and I forgot most things I found when I did this. But as far as I remember, there are ways to filter by username, but it’s not a one liner like
taskkill.Feel free to close this issue if you don’t think this will be a problem for other users. If I have some time in a few days, I can try to get back at this and add the filter by username, then I could create a PR.
I see, so it still might be a problem with the filters, since it’s killing based on the name, and not PID, it might kill both if they are running at the same time. If my assumption is correct, it’s still all tied to the filters missing, which is possible to implement, but in my solution, I didn’t.
I have applied the “workaround” mentioned above using
patch-packageand now it’s all working in my end. In summary I updated the file allowOnlyOneInstallerInstance.nsh by replacing alltaskkillcommands towmic process where name="<my_app>" call terminate. The only “issue” about this is that it doesn’t have some filters thattaskkillhad, like/fi "PID ne $pidor/fi "USERNAME eq %USERNAME%".