Skip to content

Harden app shutdown so Exit fully terminates process#323

Merged
zortos293 merged 1 commit intodevfrom
capy/harden-app-shutdown
Apr 16, 2026
Merged

Harden app shutdown so Exit fully terminates process#323
zortos293 merged 1 commit intodevfrom
capy/harden-app-shutdown

Conversation

@zortos293
Copy link
Copy Markdown
Collaborator

@zortos293 zortos293 commented Apr 16, 2026

This PR hardens the Electron app shutdown path so selecting Exit reliably terminates the process instead of leaving it running headless. Previously, calling app.quit() from the QUIT_APP IPC handler relied on the normal window-close path while long-lived timers, websockets, and Discord RPC could keep the process alive indefinitely.

Shutdown orchestration (src/main/index.ts):

  • Add runShutdownCleanup() to idempotently stop refreshScheduler, disconnect signalingClient, dispose appUpdater, destroy mainWindow, and tear down Discord RPC
  • Add requestAppShutdown() to coordinate explicit quit requests, running cleanup before app.quit() and optionally scheduling a 2s fallback to app.exit(0)
  • Route IPC_CHANNELS.QUIT_APP through requestAppShutdown() with force-exit fallback enabled
  • Reuse centralized cleanup in before-quit instead of duplicating logic
  • Add isShutdownRequested/isShutdownCleanupComplete guards and will-quit/quit handlers to cancel fallback timers on normal termination
  • Block activate recreation if shutdown is already requested

Updater coordination (src/main/index.ts, src/main/updater.ts):

  • Add onBeforeQuitAndInstall/onQuitAndInstallError hooks to AppUpdaterControllerOptions
  • Call hooks in quitAndInstall() to set/clear isUpdaterInstallQuitInProgress flag
  • Suppress force-exit fallback during updater-driven install/restart to avoid disrupting updater.quitAndInstall()

Timer hardening (src/main/updater.ts, src/main/services/refreshScheduler.ts, src/main/gfn/signaling.ts):

  • Call .unref() on startupTimer, intervalTimer, refreshTimer, and heartbeatTimer so they do not keep the process alive on their own

Open OPE-067 OPE-067

@zortos293 zortos293 added the capy Generated by capy.ai label Apr 16, 2026 — with Capy AI
@zortos293 zortos293 merged commit ef3043b into dev Apr 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant