electron-userland / electron-userland/electron-builder

Linux: the app freezes while the elevation dialog is open (spawnSync install)

Open
#10,092 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.7k
Forks
1.9k
Avg merge
3d 12h
Merged PRs (30d)
48

Description

* **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), `deb` target — the same code path serves `rpm` and `pacman`
* **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](https://github.com/electron-userland/electron-builder/blob/0a0c683d81993a63d4c64dfa67e42fa6fc41267d/packages/electron-updater/src/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

1. Package an app with the `deb` target and install it (`sudo dpkg -i app.deb`).
2. Publish a newer version and let the app download it.
3. Call `quitAndInstall()` (or `installPendingUpdateIfAvailable()` on `master`).
4. 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](https://github.com/electron-userland/electron-builder/blob/0a0c683d81993a63d4c64dfa67e42fa6fc41267d/packages/electron-updater/src/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](https://github.com/electron-userland/electron-builder/blob/0a0c683d81993a63d4c64dfa67e42fa6fc41267d/packages/electron-updater/src/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.

Contributor guide

Open the contributing guide

Research direction

Start with packages/electron-updater/src/LinuxUpdater.ts around runCommandWithSudoIfNeeded and spawnSyncLog, then read the sync-install constraints in BaseUpdater.ts around doInstall, install, and installPendingUpdateIfAvailable. Reproduce with a delayed polkit prompt on Linux and verify that explicit installation paths remain responsive while the on-quit constraint is preserved; the issue author notes a patch is already forthcoming.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, typescript
Domain
desktop, release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.