bug(updater): Linux quitAndInstall has no relaunch verification, app can go silently dead after nightly update
Bug
On Linux, an auto-update relaunch (either the "Restart to update" button or an automatic install-on-quit) can leave the desktop app completely dead: no Electron process, no bundled daemon, nothing, indefinitely, with no error surfaced to the user. Only discovered because the previous session's daemon.log stopped abruptly and ~/.ao/staged-update.json plus ~/.ao/update-restart/relaunch-flag.json were both present on disk with a fromPID for a process that no longer existed. No new process of any kind was running until the app was manually relaunched from its AppImage over 5 hours later.
Source: local occurrence, self-diagnosed | Reported by: @Ayash-Bera | Analyzed against: 3e46ad3b4 (origin/main)
Confidence: Medium
Reproduction
- Run the Linux AppImage build with the nightly channel enabled and auto-update on.
- Let the app detect and stage a new nightly (
staged-update.jsonwritten viastagedUpdateFile()inauto-updater.ts). - Let it call
quitAndInstallUpdate(), which invokesautoUpdater.quitAndInstall(false, true), either via the "Restart to update" button or an automatic install-on-quit. - If electron-updater's
AppImageUpdaterinstall/relaunch step fails for any reason (the outer AppImage path not matching whatprocess.env.APPIMAGEreports, a--appimage-extract-and-runtemp mount getting cleaned up mid-flight, a transient install error, etc), the old process has already quit and no new process is spawned. - Result:
~/.ao/staged-update.jsonand~/.ao/update-restart/relaunch-flag.jsonare left on disk referencing a dead PID, and the app is simply gone. Nothing running, nothing visible, no dialog, no crash report.
Not consistently reproducible on demand (I could not force step 4 to fail synthetically without patching electron-updater). This is a report of a real occurrence with full forensic detail from the state left behind, not a lab repro.
Root Cause
frontend/src/main/auto-updater.ts's quitAndInstallUpdate() (around L2094-2114) calls autoUpdater.quitAndInstall(false, true) unconditionally on non-darwin platforms. Compare to the macOS path:
getMacInstallBlocker()(around L2035-2068) checks the running bundle's location is writable before letting the click proceed, and shows a blocking dialog if not.applyInstallOnQuitPolicy()(around L2076-2090) disablesautoInstallOnAppQuitwhen that blocker fires, so a bad install-on-quit never fires silently.- The native macOS helper (
mac-update-progress.ts) additionally watches for the install to actually complete via its ownupdate-restart/active.jsonmarker and terminate handshake.
There is no equivalent for Linux (or Windows): no preflight check that the install can succeed from the app's current location, and per frontend/src/main/update-relaunch-flag.ts's own doc comment, "here it is the only such signal (no native helper)" for non-darwin, meaning nothing on Linux confirms the relaunch actually happened. If quitAndInstall()'s underlying install/relaunch fails on Linux, the app quits anyway and there is no watchdog, no retry, and no user-facing error.
This is adjacent to but distinct from #3679 (identity-mismatch after relaunch, which does self-recover within seconds via the daemon_unreachable fallback path). In my case there was no self-recovery at all, for over 5 hours, because no new process of any kind ever started.
It is also distinct from PR #5206's "No update filepath provided" fix, which addresses a specific electron-updater in-memory-state gap on quit-and-install and clears stale staged-update.json after 3 failed automatic checks, but nothing there retries or verifies that a successful quitAndInstall() call actually produced a running process.
Fix
Add a Linux equivalent of the macOS relaunch-verification pattern:
- Preflight: verify the AppImage path (
process.env.APPIMAGE) is writable before callingquitAndInstall(), mirroring the macOS bundle/parent-writable check. - Post-install watchdog: some independent, minimal mechanism (a small detached watcher process spawned right before quit, checked on a short timer) that can tell if the relaunch never happened and either retry or surface an error, since
markUpdateRelaunch()'s flag inupdate-relaunch-flag.tsis currently only ever consumed by the app itself on its next boot, which never comes if the boot never happens. - At minimum: do not leave
staged-update.jsonpointing at a version that was never actually reached, so the next manual launch does not inherit confusing state.
Impact
- The app can go from fully working to completely unresponsive and invisible with zero error surfaced, indistinguishable from "did I break my install" for the user.
- Manual recovery requires knowing to inspect
~/.ao/*.jsonand relaunch the AppImage directly. Not discoverable by an average user.
Related
@codebanditssss Please verify this