agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

bug(updater): Linux quitAndInstall has no relaunch verification, app can go silently dead after nightly update

Open Ayash-Bera opened this issue 2 months ago • 1 comments

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

  1. Run the Linux AppImage build with the nightly channel enabled and auto-update on.
  2. Let the app detect and stage a new nightly (staged-update.json written via stagedUpdateFile() in auto-updater.ts).
  3. Let it call quitAndInstallUpdate(), which invokes autoUpdater.quitAndInstall(false, true), either via the "Restart to update" button or an automatic install-on-quit.
  4. If electron-updater's AppImageUpdater install/relaunch step fails for any reason (the outer AppImage path not matching what process.env.APPIMAGE reports, a --appimage-extract-and-run temp mount getting cleaned up mid-flight, a transient install error, etc), the old process has already quit and no new process is spawned.
  5. Result: ~/.ao/staged-update.json and ~/.ao/update-restart/relaunch-flag.json are 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) disables autoInstallOnAppQuit when 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 own update-restart/active.json marker 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 calling quitAndInstall(), 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 in update-relaunch-flag.ts is 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.json pointing 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/*.json and relaunch the AppImage directly. Not discoverable by an average user.

Related

  • #3679: relaunch-to-update identity mismatch, same subsystem, but self-recovers; this does not.
  • PR #5206: related non-darwin quitAndInstall hardening, does not cover this path.
  • #3528: same silent-failure pattern on Windows/Squirrel (ENOSPC), different platform and mechanism.

Ayash-Bera avatar Sep 18 '26 06:09 Ayash-Bera

@codebanditssss Please verify this

Rishet11 avatar Oct 29 '26 19:10 Rishet11