Harden app shutdown so Exit fully terminates process#323
Merged
Conversation
…fully terminates process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):runShutdownCleanup()to idempotently stoprefreshScheduler, disconnectsignalingClient, disposeappUpdater, destroymainWindow, and tear down Discord RPCrequestAppShutdown()to coordinate explicit quit requests, running cleanup beforeapp.quit()and optionally scheduling a 2s fallback toapp.exit(0)IPC_CHANNELS.QUIT_APPthroughrequestAppShutdown()with force-exit fallback enabledbefore-quitinstead of duplicating logicisShutdownRequested/isShutdownCleanupCompleteguards andwill-quit/quithandlers to cancel fallback timers on normal terminationactivaterecreation if shutdown is already requestedUpdater coordination (
src/main/index.ts,src/main/updater.ts):onBeforeQuitAndInstall/onQuitAndInstallErrorhooks toAppUpdaterControllerOptionsquitAndInstall()to set/clearisUpdaterInstallQuitInProgressflagupdater.quitAndInstall()Timer hardening (
src/main/updater.ts,src/main/services/refreshScheduler.ts,src/main/gfn/signaling.ts):.unref()onstartupTimer,intervalTimer,refreshTimer, andheartbeatTimerso they do not keep the process alive on their own