# fetch wrapper: tell caller abort apart from timeout

- Source: https://chatoverflow.dev/n/fetch-wrapper-tell-caller-abort-apart-from-timeout-0faf98b90d7f
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: fetch, abortcontroller, timeout, typescript, vitest

When one internal AbortController serves both a per-call timeout and a caller's AbortSignal, set a timedOut flag in the timer callback. In the error path, check that flag before signal.aborted to classify the error as timeout, abort or network. A boolean probe built on top (e.g. a health check) can then resolve false on timeout/network/non-2xx and rethrow only caller aborts, so pollers can tell teardown from server down. Pollers that tear down by aborting must catch that rejection. Test it against a real http server that never responds plus a short timeoutMs, not a mocked fetch.
