Skip to content

fix(updater): use app.quit() instead of app.exit(0) to allow installer launch#8

Draft
normal-coder wants to merge 3 commits into
lovstudio:mainfrom
normal-coder:fix/updater-quit-and-install
Draft

fix(updater): use app.quit() instead of app.exit(0) to allow installer launch#8
normal-coder wants to merge 3 commits into
lovstudio:mainfrom
normal-coder:fix/updater-quit-and-install

Conversation

@normal-coder

@normal-coder normal-coder commented Jun 20, 2026

Copy link
Copy Markdown

Description

This Pull Request resolves the issue described in #7.

After downloading an update and clicking "Restart", the app exits but the installer never launches — the app restarts at
the same version.

Root cause: The before-quit handler unconditionally calls event.preventDefault(), blocking app.quit() from proceeding. The
shutdown flow in beginShutdown() then calls app.exit(0), which terminates the process immediately without firing the
will-quit event. Since electron-updater relies on will-quit to launch the installer (autoInstallOnAppQuit = true), the
update is downloaded but never applied.

Changes

  1. Fix the issue of failed normal update and restart
    • src/main/index.ts

      • Move event.preventDefault() after the shutdownStarted guard in the before-quit handler, so the second app.quit() (from
        beginShutdown()) is not blocked and can trigger will-quit
      • Replace app.exit(0) with app.quit() in beginShutdown() to allow the will-quit event to fire
    • src/renderer/lib/stores/update-store.ts

      • Add missing early return in download() and install() error paths
  2. Fix the issue where the update progress bar displays incorrectly

Flow Before Fix

app.quit() → before-quit → event.preventDefault() → beginShutdown()
→ async cleanup → app.exit(0) → process dies → will-quit never fires

Flow After Fix

app.quit() → before-quit → event.preventDefault() → beginShutdown()
→ async cleanup → app.quit() (second call)
→ before-quit → shutdownStarted=true → return (no prevent)
→ will-quit fires → installer launches → update applied

Testing

  • pnpm run format
  • pnpm run lint
  • pnpm run typecheck
  • pnpm run test ✅ (945/945 tests pass; 5 unrelated env-specific failures)

…r launch

fix lovstudio#7

Signed-off-by: 诺墨 <normal@normalcoder.com>
Signed-off-by: 诺墨 <normal@normalcoder.com>
@normal-coder normal-coder marked this pull request as draft June 21, 2026 06:35
Signed-off-by: 诺墨 <normal@normalcoder.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant