* Creates a fetch wrapper that enforces the XAA request timeout and optionally * composes a caller-provided abort signal. Using AbortSignal.any ensures the * user's cancel (e.g. Esc in the auth menu) actually aborts in-flight requests * rather than being clobbered by the timeout signal.
(abortSignal?: AbortSignal)
| 40 | * rather than being clobbered by the timeout signal. |
| 41 | */ |
| 42 | function makeXaaFetch(abortSignal?: AbortSignal): FetchLike { |
| 43 | return (url, init) => { |
| 44 | const timeout = AbortSignal.timeout(XAA_REQUEST_TIMEOUT_MS) |
| 45 | const signal = abortSignal |
| 46 | ? // eslint-disable-next-line eslint-plugin-n/no-unsupported-features/node-builtins |
| 47 | AbortSignal.any([timeout, abortSignal]) |
| 48 | : timeout |
| 49 | // eslint-disable-next-line eslint-plugin-n/no-unsupported-features/node-builtins |
| 50 | return fetch(url, { ...init, signal }) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | const defaultFetch = makeXaaFetch() |
| 55 |
no outgoing calls
no test coverage detected