Repository navigation
fix(main): cancel active update-check requests when enabling Offline mode - #1327
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Intent
Verify this review finding and, if true, fix it: Cancel active update checks when enabling Offline mode (
main/index.tsaround line 437). The handler suppresses update-check results without cancelling the provider's requests. A controlled reproduction issued two additional GitHub metadata requests after the UI reported "offline". Cancel the request chain when the mode changes.What Changed
linkUpdateCheckRequestsinmain/updater-shutdown.tsto attach the active update-checkCancellationTokenas the parent of eachautoUpdater.httpExecutorrequest token.CancellationTokeninmain/index.tsduringcheckForUpdates()and cancelled it insuspendUpdaterForOfflineMode'sinvalidateCheckcallback so enabling Offline mode aborts in-flight provider requests and stops subsequent requests in the chain.tests/offline-mode.test.tsverifying that enabling Offline mode aborts the in-flightGitHubProviderrelease-feed request and issues no further metadata requests.Risk Assessment
✅ Low: The change is a small, well-bounded fix that attaches a per-check CancellationToken to autoUpdater.httpExecutor requests and cancels it when Offline mode is enabled, backed by a direct behavioral test against GitHubProvider.
Testing
Ran the focused
test:offline-modeand updater unit suites, then built and launched the packaged Electron desktop app (Flo Cafe.app) against an isolated SQLite profile and a disposable local HTTP update server configured viaapp-update.yml. Drove three live scenarios through the Settings UI: aborting an in-flightreleases.atomrequest when enabling Offline mode (confirming zero follow-up requests), aborting a mid-chain/releases/latestrequest afterreleases.atomsucceeded (confirminglatest-mac.ymlis never requested), and re-enabling online mode to verify a subsequent manual update check completes all three metadata requests and rendersv99.0.0as available, capturing UI screenshots and wire-level request/abort logs.Evidence: Live Electron updater request and abort trace across all three scenarios
{ "scenario1": { "statusBeforeOffline": "checking", "statusAfterOffline": { "status": "offline", "reason": "unknown", "error": "Offline mode is on" }, "receivedRequests": [{ "method": "GET", "url": "/FreeOpenSourcePOS/FloCafe/releases.atom", "mode": "hold-atom" }], "abortedRequests": [{ "url": "/FreeOpenSourcePOS/FloCafe/releases.atom", "mode": "hold-atom" }] }, "scenario2": { "statusAfterOffline": { "status": "offline", "reason": "unknown", "error": "Offline mode is on" }, "receivedRequests": [ { "method": "GET", "url": "/FreeOpenSourcePOS/FloCafe/releases.atom", "mode": "hold-latest-tag" }, { "method": "GET", "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest", "mode": "hold-latest-tag" } ], "abortedRequests": [{ "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest", "mode": "hold-latest-tag" }] }, "scenario3": { "finalStatus": { "status": "available", "version": "99.0.0" }, "receivedRequests": [ { "method": "GET", "url": "/FreeOpenSourcePOS/FloCafe/releases.atom", "mode": "respond-all" }, { "method": "GET", "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest", "mode": "respond-all" }, { "method": "GET", "url": "/FreeOpenSourcePOS/FloCafe/releases/download/v99.0.0/latest-mac.yml", "mode": "respond-all" } ], "abortedRequests": [] } }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:offline-modenpm run test:update-statenpm run test:update-uinpm run test:update-channelnpm run test:update-ipc-sender-validationLive Playwright Electron session against packagedFlo Cafe.appwith disposable local HTTP GitHub update server exercising initial-request abort, mid-chain/releases/latestabort, and post-reconnect update discovery✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.