Skip to content

fix(main): cancel active update-check requests when enabling Offline mode - #1327

Merged
khaira777 merged 3 commits into
mainfrom
fm/ship-offline-update-check-cancel
Oct 23, 2026
Merged

khaira777 merged 3 commits into
mainfrom
fm/ship-offline-update-check-cancel

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Verify this review finding and, if true, fix it: Cancel active update checks when enabling Offline mode (main/index.ts around 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

  • Added linkUpdateCheckRequests in main/updater-shutdown.ts to attach the active update-check CancellationToken as the parent of each autoUpdater.httpExecutor request token.
  • Tracked a per-check CancellationToken in main/index.ts during checkForUpdates() and cancelled it in suspendUpdaterForOfflineMode's invalidateCheck callback so enabling Offline mode aborts in-flight provider requests and stops subsequent requests in the chain.
  • Added an offline-mode test in tests/offline-mode.test.ts verifying that enabling Offline mode aborts the in-flight GitHubProvider release-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-mode and 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 via app-update.yml. Drove three live scenarios through the Settings UI: aborting an in-flight releases.atom request when enabling Offline mode (confirming zero follow-up requests), aborting a mid-chain /releases/latest request after releases.atom succeeded (confirming latest-mac.yml is never requested), and re-enabling online mode to verify a subsequent manual update check completes all three metadata requests and renders v99.0.0 as available, capturing UI screenshots and wire-level request/abort logs.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Owner starts an update check in Settings -> Software Updates and switches Offline mode ON in Settings -> Privacy while the release-feed request (releases.atom) is in flight; the UI transitions to Offl… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/01-update-checking-in-flight.png, ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/02-offline-mode-aborted-…
Adversarial mid-chain boundary: Owner switches Offline mode ON after releases.atom completes while the second GitHub metadata request (/api/v3/repos/.../releases/latest) is in flight; the second reque… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/live-updater-offline-cancellation-evidence.json
Recovery after cancellation: Owner switches Offline mode back OFF and clicks Check for Updates; a fresh CancellationToken is used, all three GitHub metadata requests complete without cancellation, and… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/03-update-available-after-reconnect.png and ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/live-updater-o…

Update check in flight before enabling Offline mode
Update check aborted and UI transitioned to Offline after enabling Offline mode
Update check completes 3-request chain and reports v99.0.0 available after disabling Offline mode

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": [] } }

{
  "scenario1": {
    "statusBeforeOffline": "checking",
    "statusAfterOffline": {
      "status": "offline",
      "reason": "unknown",
      "error": "Offline mode is on",
      "info": {
        "version": "3.13.0"
      }
    },
    "receivedRequests": [
      {
        "method": "GET",
        "url": "/FreeOpenSourcePOS/FloCafe/releases.atom",
        "mode": "hold-atom",
        "ts": 1792767429021
      }
    ],
    "abortedRequests": [
      {
        "url": "/FreeOpenSourcePOS/FloCafe/releases.atom",
        "mode": "hold-atom",
        "ts": 1792767429281
      }
    ]
  },
  "scenario2": {
    "statusAfterOffline": {
      "status": "offline",
      "reason": "unknown",
      "error": "Offline mode is on",
      "info": {
        "version": "3.13.0"
      }
    },
    "receivedRequests": [
      {
        "method": "GET",
        "url": "/FreeOpenSourcePOS/FloCafe/releases.atom",
        "mode": "hold-latest-tag",
        "ts": 1792767430377
      },
      {
        "method": "GET",
        "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest",
        "mode": "hold-latest-tag",
        "ts": 1792767430389
      }
    ],
    "abortedRequests": [
      {
        "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest",
        "mode": "hold-latest-tag",
        "ts": 1792767430491
      }
    ]
  },
  "scenario3": {
    "finalStatus": {
      "status": "available",
      "version": "99.0.0",
      "info": {
        "version": "3.13.0"
      }
    },
    "receivedRequests": [
      {
        "method": "GET",
        "url": "/FreeOpenSourcePOS/FloCafe/releases.atom",
        "mode": "respond-all",
        "ts": 1792767431070
      },
      {
        "method": "GET",
        "url": "/api/v3/repos/FreeOpenSourcePOS/FloCafe/releases/latest",
        "mode": "respond-all",
        "ts": 1792767431073
      },
      {
        "method": "GET",
        "url": "/FreeOpenSourcePOS/FloCafe/releases/download/v99.0.0/latest-mac.yml",
        "mode": "respond-all",
        "ts": 1792767431080
      }
    ],
    "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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Owner starts an update check in Settings -> Software Updates and switches Offline mode ON in Settings -> Privacy while the release-feed request (releases.atom) is in flight; the UI transitions to Offl… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/01-update-checking-in-flight.png, ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/02-offline-mode-aborted-…
Adversarial mid-chain boundary: Owner switches Offline mode ON after releases.atom completes while the second GitHub metadata request (/api/v3/repos/.../releases/latest) is in flight; the second reque… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/live-updater-offline-cancellation-evidence.json
Recovery after cancellation: Owner switches Offline mode back OFF and clicks Check for Updates; a fresh CancellationToken is used, all three GitHub metadata requests complete without cancellation, and… ✅ pass live ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/03-update-available-after-reconnect.png and ~/.no-mistakes/evidence/01M5MK8XQMZ7NZ1CRMGAFJ0GFW/live-updater-o…
  • npm run test:offline-mode
  • npm run test:update-state
  • npm run test:update-ui
  • npm run test:update-channel
  • npm run test:update-ipc-sender-validation
  • Live Playwright Electron session against packaged Flo Cafe.app with disposable local HTTP GitHub update server exercising initial-request abort, mid-chain /releases/latest abort, and post-reconnect update discovery
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777
khaira777 enabled auto-merge (squash) October 23, 2026 15:16
@khaira777
khaira777 merged commit 48bdedf into main Oct 23, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/ship-offline-update-check-cancel branch October 23, 2026 15:25
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