fix(updater): break the auto-update restart/install loop#641
Merged
Conversation
Routing the install through the graceful-shutdown path left three defects that prevented downloaded updates from ever applying: - before-quit ended the normal-quit branch with app.exit(0), which skips the `quit` event and silently disables electron-updater's autoInstallOnAppQuit. Use app.quit() so a downloaded update installs on a normal quit (re-entrant before-quit returns early on isShuttingDown, so the quit still completes). - closeVault() during shutdown broadcast isOpen:false to the renderer, flipping the UI to the vault picker mid-restart. Gate the renderer status broadcast once shutdown begins via beginVaultShutdown(). - keep the explicit performQuitAndInstall() path for signed builds. Adds main-process tests for the quit terminator (app.quit not app.exit) and the install handoff (performQuitAndInstall when requested).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Problem
After downloading an update, clicking Restart did not relaunch the app. Instead the window flipped to the vault picker, the app stayed alive, and a second Restart click quit without installing. Reopening still offered the same update — an infinite loop, the app never updated.
Root cause
The install was routed through the generic graceful-shutdown path, which had three compounding defects (PR #570 fixed the install handoff but not these):
app.exit(0)on the normal-quit branch skips thequitevent, which silently disables electron-updater'sautoInstallOnAppQuit(BaseUpdater.addQuitHandlerhooksapp.onQuit). A downloaded update could never install on a normal quit.closeVault()during shutdown broadcastisOpen:falseto the renderer, flipping the UI to the vault picker mid-restart (single window resizes to picker size).performQuitAndInstall()path was kept, but combined with the above the app could end up alive on the picker with no way to recover in-session.Fix
apps/desktop/src/main/index.ts: before-quit normal branchapp.exit(0)→app.quit()so thequitevent fires and a downloaded update installs on any normal quit. The re-entrant before-quit returns early onisShuttingDown(nopreventDefault), so the quit still completes.apps/desktop/src/main/vault/index.ts: newbeginVaultShutdown();emitStatusChanged()stops the renderervault:status-changedbroadcast once shutdown begins, called at the start of before-quit → no more picker flip.performQuitAndInstall()path for signed builds.Tests
app.quit(notapp.exit); hands off toperformQuitAndInstallwhen an install was requested.rebuild:node;typecheck:node+ eslint clean.Verification note
The final Squirrel.Mac bundle swap is
app.isPackaged-only and can't be unit-tested. The logic above is verifiable locally (see testing recipe); a signed build is only needed to confirm the actual on-disk swap. A broken release can only be repaired by the next release (updater bootstrap), so this lands the correct behavior going forward.