fix: set a default timeout for REST requests#1025
Merged
Merged
Conversation
Requests through the CoderApi axios instance had no timeout, so a request hung on a half-open TCP connection (network drop, system sleep) never settled. This silently killed every poller that only reschedules after the previous request settles: announcements refresh, the workspaces tree poll, and the OAuth background token refresh. Set a 60s default on the shared instance. Streaming responses (SSE, CLI binary download) are unaffected past the header phase: axios only enforces the timeout until response headers arrive and never aborts an in-flight stream body. Closes #1024
mtojek
approved these changes
Jul 8, 2026
90a16eb to
74fcdcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1024
Requests through the
CoderApiaxios instance had no timeout, so a request hung on a half-open TCP connection (network drop, system sleep) never settled — silently killing every poller that only reschedules after the previous request settles (announcements refresh, workspaces tree poll, OAuth token refresh).Changes
defaults.timeout = 60_000on the shared axios instance inCoderApi.create.Why no stream exemptions
The issue proposed
{ timeout: 0 }opt-outs for streaming calls, but they aren't needed: in axios's Node adapter,responseType: "stream"requests are marked done once response headers arrive, so the timeout only bounds the connect/header phase and never aborts an in-flight stream body. SSE streams and CLI downloads just get a bounded connect phase, which is desirable. Build endpoints return as soon as the build is queued, so nothing REST-side legitimately exceeds 60s.Timeouts surface as regular axios network errors, handled by existing
errToStr/retry paths.Decision log
coder/codersite sets no axios timeout, and Gocodersdkuses a barehttp.Client{}bounded by per-request contexts.coder.requestTimeoutsetting rejected as premature configurability.🤖 Generated by Coder Agents on behalf of @EhabY