fix(desktop): dont 500 the installer download when Gitea releases is unreachable (BIT-31961) #133

Merged
spark merged 1 commits from fix/BIT-31961-desktop-download-fetch-failed into main 2026-11-01 01:02:47 +00:00
Owner

Summary

  • GET /v1/desktop/download/:releaseId/:name called DesktopReleases.file() with no try/catch, unlike the sibling update-check route. A transient network failure reaching the Gitea releases API threw a raw undici TypeError: fetch failed straight through the route, 500ing the desktop client and reaching errors.bitreport.pt with no file/line (the native undici error has no frame pointing into our code).
  • Wraps the call in a try/catch like the sibling /v1/desktop/update/... route already does: logs a warning and answers 503 { error: "download_unavailable" } instead of a 500.

Origin: BIT-31961 (error-loop ticket, ERRCLUSTER 937cdb6ca64d, freq 1, no stack location). Traced to apps/api/src/desktop/updates.ts by checking every fetch/fetchImpl call site in apps/api for one that neither wraps network failures into a descriptive error (like zerozero/nextcloud do) nor catches them at the call site.

Test plan

  • apps/api/test/desktop-updates.test.ts — added a regression test that injects a rejecting fetchImpl and asserts the route answers 503 instead of throwing (npx vitest run test/desktop-updates.test.ts, 4/4 passing).
  • npx tsc --noEmit clean.
## Summary - `GET /v1/desktop/download/:releaseId/:name` called `DesktopReleases.file()` with no try/catch, unlike the sibling update-check route. A transient network failure reaching the Gitea releases API threw a raw undici `TypeError: fetch failed` straight through the route, 500ing the desktop client and reaching errors.bitreport.pt with no file/line (the native undici error has no frame pointing into our code). - Wraps the call in a try/catch like the sibling `/v1/desktop/update/...` route already does: logs a warning and answers `503 { error: "download_unavailable" }` instead of a 500. Origin: BIT-31961 (error-loop ticket, ERRCLUSTER 937cdb6ca64d, freq 1, no stack location). Traced to `apps/api/src/desktop/updates.ts` by checking every `fetch`/`fetchImpl` call site in apps/api for one that neither wraps network failures into a descriptive error (like zerozero/nextcloud do) nor catches them at the call site. ## Test plan - [x] `apps/api/test/desktop-updates.test.ts` — added a regression test that injects a rejecting `fetchImpl` and asserts the route answers 503 instead of throwing (`npx vitest run test/desktop-updates.test.ts`, 4/4 passing). - [x] `npx tsc --noEmit` clean.
spark added 1 commit 2026-11-01 00:24:47 +00:00
fix(desktop): don't 500 the installer download when Gitea releases is unreachable (BIT-31961)
ci / rust (pull_request) Successful in 3m54s
ci / typescript (pull_request) Successful in 8m1s
c652715707
GET /v1/desktop/download/:releaseId/:name called DesktopReleases.file()
with no try/catch, unlike the sibling update-check route. A transient
network failure fetching the release/asset from Gitea threw a bare
undici TypeError (no file/line in its stack, since it originates
inside undici) straight through the route handler, landing on the
error hub as an unlocatable "TypeError: fetch failed" and a 500 to the
desktop app instead of a graceful retry signal.

Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8)
Paperclip-Issue: BIT-31961
Paperclip-Run: 431a287c-0cb3-4f73-9288-ac8d20e18df8
paperclip-review-bot left a comment
Member

auto-approve: CI success on c652715707 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on c652715707cd (gitea_auto_approve_open_prs_once.py)
founding-engineer left a comment
Member

auto-approve: CI success on c652715707 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on c652715707cd (gitea_auto_approve_open_prs_once.py)
devops-engineer left a comment
Member

auto-approve: CI success on c652715707 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on c652715707cd (gitea_auto_approve_open_prs_once.py)
spark scheduled this pull request to auto merge when all checks succeed 2026-11-01 01:02:46 +00:00
spark merged commit 7a552e2c81 into main 2026-11-01 01:02:47 +00:00
Sign in to join this conversation.