Skip to content

fix(app): time out requests the server never answers - #47572

Merged
Hona merged 1 commit into
anomalyco:v2from
Hona:request-headers-timeout
Sep 6, 2026
Merged

fix(app): time out requests the server never answers#47572
Hona merged 1 commit into
anomalyco:v2from
Hona:request-headers-timeout

Conversation

@Hona

@Hona Hona commented Sep 6, 2026

Copy link
Copy Markdown
Member

A socket that dies while a phone sleeps can leave fetch waiting for response headers until the OS gives up on TCP retransmits, which is minutes on Android and Linux. The request queue allows four in-flight requests per server, so a few of those dead requests wedge every later API call, and the only symptom is a server thrashing detected console warning.

  • Each queued request now gets a 60 s headers deadline. If no response arrives by then the request is aborted with a TimeoutError and its slot is released.
  • The deadline covers headers only; once the response arrives the body may stream for as long as it needs.
  • Caller AbortSignals still propagate to the underlying request.
  • /api/event keeps its existing bypass; the event stream has its own idle watchdog.
const controller = new AbortController()
request.signal.addEventListener("abort", () => controller.abort(request.signal.reason), { once: true })
const timer = setTimeout(
  () => controller.abort(new DOMException("Timed out waiting for the server to respond", "TimeoutError")),
  headersTimeoutMs,
)
return base(new Request(request, { signal: controller.signal })).finally(() => {
  clearTimeout(timer)
  release(entry)
})

Touches the same file as #47564; the conflict is confined to the test setup helper and the fetch body.

@Hona
Hona requested a review from Brendonovich as a code owner September 6, 2026 03:55
Copilot AI lite review requested due to automatic review settings September 6, 2026 03:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona merged commit cf212a4 into anomalyco:v2 Sep 6, 2026
10 checks passed
@Hona
Hona deleted the request-headers-timeout branch September 6, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants