fix(desktop): treat a 5xx on the update feed as transient instead of an update error

Merged
SA
2mo ago
+91-8

Problem

The desktop's scheduled update check sometimes gets a server error back from GitHub while fetching the feed manifest (latest-mac.yml): a 5xx from GitHub's edge during an incident, or a nonstandard 618 jwt:expired from its asset CDN when the app followed the signed redirect after the token's five-minute window, which is a laptop that slept mid-check. Both are transient and retried by the next check four hours later, but the updater handled them as a real failure:

  • reported an HttpError to Sentry (DESKTOP-18M; the same class has ~640 events in DESKTOP-QX over 90 days),
  • showed the error pill with the raw response HTML in its tooltip,
  • cleared any staged update.

Root cause

isNetworkError in auto-updater.ts only knows the transport failure shapes (net::ERR_*, ENOTFOUND, …). electron-updater rejects a failed feed fetch with its own HttpError, whose message begins with the status code and carries statusCode as a property. Nothing classified it, so a 504 from the update server took the same path as a genuine feed defect. PR #7283 noted this class as out of scope when it classified the download-side 5xx.

Fix

isUpstreamServerError in update-error-classification.ts classifies an HttpError whose statusCode is 500 or above. auto-updater.ts lets it pass in silence at the two background sites (the error event handler and the scheduled check's rejection), exactly like a transport error. The interactive "Check for updates" path is unchanged: it still shows its "Update Error, try again later" dialog, since the user asked.

A 4xx keeps reporting: a feed that is not there is ours to publish. The classifier also does not match electron-updater's own Cannot download …, status 5xx message (a different rule in the same file covers that) or anything that is not an HttpError.

Verification

$ bunx biome check apps/desktop/src/main/lib/auto-updater.ts apps/desktop/src/main/lib/update-error-classification.ts apps/desktop/src/main/lib/update-error-classification.test.ts
Checked 3 files in 24ms. No fixes applied.

$ cd apps/desktop && bun run typecheck
$ tsc --noEmit
(no errors)

$ cd apps/desktop && bun test src/main/lib
 693 pass
 0 fail
 1404 expect() calls
Ran 693 tests across 48 files. [1.86s]

Negative test written first: the new tests failed before the classifier existed, and with the threshold mutated to >= 400 the "keeps reporting a client error" test fails:

(fail) isUpstreamServerError > keeps reporting a client error: an asset that is not there is ours
 18 pass
 1 fail

Refs DESKTOP-18M

https://claude.ai/code/session_01Qgf75dZfWinAqmZEce8smM


Summary by cubic

Treats 5xx responses on the update feed as transient during scheduled checks, so the desktop updater no longer reports them to Sentry, shows the error pill, or clears a staged update. This covers GitHub's edge answering 5xx during an incident and the asset CDN answering 618 jwt:expired when a signed redirect expires mid-check. Refs DESKTOP-18M.

Bug Fixes

  • Classifies HttpError status codes 500 and above as transient at the two background capture sites.
  • Keeps 4xx errors reported, since a feed that is not there is ours to publish.
  • Leaves the interactive "Check for updates" error dialog unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Automatic update checks now retry when temporary update-server errors occur, in addition to network interruptions.
    • Update failures caused by temporary server issues are handled as recoverable, reducing unnecessary hard-error notifications.
    • Retry-related messages now indicate that the update server is unreachable and the update will be attempted again later.