Skip to content

The request timeout doesn't cover reading the response body #367

Open

Description

@presidojay1

src/lib/api.ts:88-101 attaches AbortSignal.timeout(timeoutMs) to the
fetch call, which resolves as soon as the response headers arrive. The
body is read afterwards, outside any timeout:

if (!res.ok) {
  const payload = await res.json().catch(() => null);   // :112
  ...
}
return res.json() as Promise<T>;                         // :120

A backend that sends 200 OK and then stalls mid-body — a hung streaming
response, a dropped TCP connection without a FIN, a proxy that times out
upstream after flushing headers — leaves these awaits pending forever. Every
page that calls apiFetch sets a loading flag before the call and clears it
in finally, so the UI stays on "Loading…" or a disabled "Working…" button
indefinitely. That is precisely the state #54 added DEFAULT_TIMEOUT_MS to
prevent, for the half of the request it doesn't cover.

Fix: keep the timeout signal alive across the body read — race the
res.json() promise against the signal's abort event, or wrap the whole
request/parse sequence in one abortable helper. src/lib/api-timeout.test.ts
currently only covers a stalled headers phase; add a stalled-body case.

Activity

  1. added
    bug
    on Nov 12, 2026
  2. added
    Stellar Wave
    on Nov 21, 2026
  3. Gentle842 commented on Nov 21, 2026

    @Gentle842

    @Gentle842 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    Hi maintenaner, I can work on this,
    Pls kindly assign it to me

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Gentle842 to this issue.

  4. hameedx01 commented on Nov 25, 2026

    @hameedx01

    @hameedx01 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    Hi, Maintainer, i would like to work on this issue, pls can you kindly assign it to me?.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @hameedx01 to this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar Wavebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions