Linux: the app freezes while the elevation dialog is open (spawnSync install)
- Electron-Builder Version: 26.15.3 — the code below is quoted from
master(27.0.0-alpha.7), where it is unchanged - Electron Updater (as-needed): 6.8.9 (and 7.0.0-alpha.6)
- Node Version: the one bundled with Electron 42.5.0
- Electron Version: 42.5.0
- Platform & Target: Linux (Ubuntu 24.04, GNOME 46, Wayland),
debtarget — the same code path servesrpmandpacman - Debug Logs: nothing is logged; the symptom is the desktop marking the app as not responding while the elevation dialog is open
What happens
LinuxUpdater.runCommandWithSudoIfNeeded installs through spawnSyncLog
(LinuxUpdater.ts#L37-L54), so the Electron main process is blocked for as long
as the polkit dialog is open — that is, while the user is typing their password. The desktop notices the
unresponsive process and offers to force-quit the app:
"App" is not responding — Force Quit / Wait
Timers cannot run either, so any app-side safety net around the install is frozen too.
Steps to reproduce
- Package an app with the
debtarget and install it (sudo dpkg -i app.deb). - Publish a newer version and let the app download it.
- Call
quitAndInstall()(orinstallPendingUpdateIfAvailable()onmaster). - When the polkit dialog appears, wait ~15 s before typing the password.
Why it is not simply "make it async"
doInstall and install are documented as must be sync (because quit even handler is not async)
(BaseUpdater.ts#L80-L83) — the constraint comes from installing inside the
app.on("quit") handler.
That constraint does not cover the paths that matter here. On master, targets whose install requires
elevation are already excluded from the automatic install at launch and go through an explicit
installPendingUpdateIfAvailable() (BaseUpdater.ts#L52-L61), and
quitAndInstall() is called by the application, not by a quit handler. Both can await an install. Only the
on-quit path cannot — and there the app is exiting anyway, so blocking is far less harmful.
I have a patch for this and will open a PR shortly.
Source: electron-userland/electron-builder