fix: centralize updater restart deferral in main process#313
Merged
AmethystLiang merged 2 commits intomainfrom Apr 5, 2026
Merged
fix: centralize updater restart deferral in main process#313AmethystLiang merged 2 commits intomainfrom
AmethystLiang merged 2 commits intomainfrom
Conversation
PR #299 introduced a regression where the one-click auto-update flow would synchronously invoke `quitAndInstall` immediately upon receiving the `downloaded` state transition. This triggered a synthetic `beforeunload` event (to capture terminal buffers) and an IPC call to quit in the exact same event loop tick that React and the Toast library were processing state updates. This disrupted the renderer's synchronous shutdown and flush logic, causing the app to fail to quit and install properly. This adds a `setTimeout` to defer `quitAndInstall`, pushing it to the bottom of the event queue. This allows the UI state to settle and ensures the `beforeunload` flush sequence executes cleanly. Test cases have also been updated to use fake timers.
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
The updater restart path depended on renderer-side timeouts. That made the quit-and-install timing differ between toast actions and other entrypoints, and it left duplicate restart requests to be handled inconsistently across surfaces.
Solution
Move the short restart deferral into the shared main-process
quitAndInstallentrypoint, add a guard so duplicate requests are ignored while the delay is pending, and cover the timing behavior with updater tests.