Skip to content

fix: centralize updater restart deferral in main process#313

Merged
AmethystLiang merged 2 commits intomainfrom
validate-auto-update
Apr 5, 2026
Merged

fix: centralize updater restart deferral in main process#313
AmethystLiang merged 2 commits intomainfrom
validate-auto-update

Conversation

@AmethystLiang
Copy link
Copy Markdown
Contributor

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 quitAndInstall entrypoint, add a guard so duplicate requests are ignored while the delay is pending, and cover the timing behavior with updater tests.

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.
@AmethystLiang AmethystLiang merged commit 6b18a1c into main Apr 5, 2026
1 check passed
@AmethystLiang AmethystLiang deleted the validate-auto-update branch April 5, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant