Skip to content

fix(cli): bound server downloads by progress instead of a fixed total deadline - #51

Open
tahodev wants to merge 1 commit into
beeper:mainfrom
tahodev:fix-50-download-idle-timeout
Open

tahodev wants to merge 1 commit into
beeper:mainfrom
tahodev:fix-50-download-idle-timeout

Conversation

@tahodev

@tahodev tahodev commented Oct 25, 2026

Copy link
Copy Markdown

Fixes #50.

Problem

downloadArtifact fetched the server/desktop artifact with a single AbortSignal.timeout(120_000) covering the whole request including the body. The linux-arm64 server archive is ~195 MB, so any connection slower than ~1.6 MB/s always aborted mid-download with "The operation timed out" - which is what the Raspberry Pi 4 reporter hits.

Change

  • Time to response headers is bounded separately (30 s): a server that never starts the download still fails fast.
  • The body is watched for progress instead of a total deadline: an idle watchdog fails the download when no data arrives for 120 s, but a slow connection that keeps receiving data is allowed to finish no matter how long it takes.
  • downloadArtifact accepts optional { responseTimeoutMs, idleTimeoutMs } (used by the tests to keep them fast; defaults are unchanged behavior-wise for healthy connections).
  • Partial files are still removed on failure (existing behavior, covered by tests).

Tests

Added three cases to packages/cli/test/installations.test.ts, all passing via bun test:

  • slow-but-progressing download completes (gaps under the idle limit, total time over it) - this fails with the old fixed 120 s deadline semantics when the same bounds are applied as a total timeout;
  • mid-body stall with an open connection rejects with a "stalled" error and leaves no partial file;
  • server that never responds rejects with a "did not respond" error and leaves no file.

bun test test/installations.test.ts: 10/10 pass. The wider suite shows 9 pre-existing failures on a clean checkout of main in this Linux sandbox (they need the built @beeper/desktop-api package, which prepare-desktop-api.ts can't fetch here); baseline-compared with a worktree of main to confirm they are unrelated.

Environment note: verified on Linux with Bun 1.4.4; I don't have a Raspberry Pi to reproduce the original report end-to-end, but the abort path is the same AbortSignal.timeout the report identifies.

PR prepared with AI assistance (various models).

… deadline

The artifact download used AbortSignal.timeout(120_000) for the whole
fetch including the body, so the ~195 MB linux-arm64 server archive
aborted on connections slower than about 1.6 MB/s.

Bound the time to the response headers (30 s) separately and watch the
body for progress instead: the download fails when the server does not
respond or when no data arrives for 120 s, but a slow connection that
keeps making progress is allowed to finish. Partial files are still
removed on failure.

Fixes beeper#50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Server install times out on slower connections (fixed 120 s limit); npm wrapper fails with EXDEV when /tmp is tmpfs

1 participant