Skip to content

Set a default timeout for REST requests #1024

Description

@EhabY

No REST request in the extension has a timeout: CoderApi never sets defaults.timeout on its axios instance and no call site passes one, so axios's default (no timeout) applies everywhere. A request hung across a network drop or system sleep (half-open TCP) never settles.

This silently kills every poller that only schedules its next run after the current request settles:

  • Announcements refresh (src/announcements/manager.ts) — next poll armed in finally after getAppearance().
  • Workspaces tree poll (src/workspace/workspacesProvider.ts, fetchAndRefresh) — maybeScheduleRefresh() runs only after the fetch settles, and this.fetching stays true, which also blocks manual refreshes.
  • OAuth background token refresh (src/oauth/sessionManager.ts, attemptRefreshWithRetry) — retry timer chained on the request settling; its AbortController only aborts on sign-out/dispose, never on time. A hung refresh means tokens silently stop refreshing.

Proposal: set a sensible default timeout on the CoderApi axios instance, with explicit overrides (or exemptions) for legitimately long-running calls such as binary downloads and build/long-poll operations.

Recommended approach

Set a default on the shared instance in CoderApi.create and opt out where a request is legitimately long:

  1. defaults.timeout = 30_000 on the CoderApi axios instance. This covers every SDK call and the OAuth token refresh, which posts through client.getAxiosInstance() (src/oauth/sessionManager.ts), so all three pollers above become hang-proof with one line.
  2. Pass { timeout: 0 } explicitly for the CLI binary download (src/core/cliManager.ts download request with responseType: "stream", same shared instance). Note axios's timeout only bounds time-to-first-response, not body streaming, but the explicit opt-out keeps slow mirrors safe and documents the intent.
  3. The ad-hoc globalAxios.create() client in cliManager should get the same 30s default when it is not downloading.
  4. Workspace build endpoints (startWorkspace etc.) return as soon as the build is queued (logs stream over websockets), so they need no exemption; verify once in CI against a real deployment before merging.

Timeout errors surface as ECONNABORTED axios errors, so existing errToStr/retry paths handle them like any other network failure.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions