fix: solve #3507 — macOS Update button silently fails after repeated clicks#3508
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
fix: solve #3507 — macOS Update button silently fails after repeated clicks#3508github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
… calls installUpdate had no guard, so every click on "Install" fired another autoUpdater.quitAndInstall(). On macOS, MacUpdater.quitAndInstall() re-registers a nativeUpdater "update-downloaded" listener when Squirrel hasn't finished downloading yet; each extra click stacks another listener, and when Squirrel finally fires the event every listener ends up calling nativeUpdater.quitAndInstall() in parallel, which can leave the downloaded binary un-swapped. Add an isInstalling guard plus a "must be READY" precondition, and reset the guard on autoUpdater errors so a failed attempt can be retried without needing to relaunch the app. Closes #3507
4 tasks
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.
Root cause
installUpdate()inapps/desktop/src/main/lib/auto-updater.tshad noguard, so every click on the Install button fired another
autoUpdater.quitAndInstall(false, true).On macOS,
MacUpdater.quitAndInstall()re-registers a native-updaterupdate-downloadedlistener every time it is called before Squirrel.Machas finished downloading. Each extra click stacks another listener —
and when Squirrel finally fires the event, every queued listener ends
up calling
nativeUpdater.quitAndInstall()in parallel. Racing thenative updater like that can leave the downloaded binary un-swapped,
which matches the user report on #3507: the app closes after clicking
Update but relaunches on the old version.
The fix
isInstallingguard so repeated clicks short-circuit instead ofre-entering
autoUpdater.quitAndInstall().currentStatus === READY; otherwise log and no-op(nothing to install).
autoUpdatererrorevent so a failed attemptcan be retried without restarting the app.
Tests
Reproduction test in
apps/desktop/src/main/lib/auto-updater.test.ts:ignores install requests when no update is ready— clicking Installbefore the download finishes no longer calls
quitAndInstall.does not invoke quitAndInstall multiple times when the install button is clicked repeatedly— three rapid clicks now result in exactly onequitAndInstallcall (pre-fix: three calls, reproducing the race).Verified that both tests fail on
mainwithout the fix and pass withthe fix applied.
Closes #3507
Summary by cubic
Fixes #3507: Prevents the macOS Update button from failing after repeated clicks by guarding installs and only running when an update is ready. This stops
electron-updaterlistener fan-out that caused relaunching on the old version.Bug Fixes
isInstallingguard to ignore duplicate clicks and avoid parallelquitAndInstall()calls.currentStatus === READY; otherwise log and no-op.autoUpdatererrorto allow retry; add tests for duplicate clicks and not-ready installs.Written for commit cd2f8b2. Summary will update on new commits.