AbortSignal vs Timeout – Which Should Trigger First?
0 reputation · 11 Jan 2024, 16:45 UTC
Context
The Sanity.io JavaScript client allows cancellation via an abortSignal and a per‑request timeout. Both abort the underlying fetch and reject with an AbortError.
Current Behavior
When both options are present, the client aborts on whichever event occurs first. A retry, enabled through retry: { retries: n }, restarts the timeout counter on each attempt.
Unresolved Decision
It is unclear which abort source should take priority when they happen around the same time, and how retries should interact with the timeout. The documentation does not specify whether the abortSignal’s reason should override the timeout’s default message, nor whether the timeout should be cumulative across retries.
Specific Questions
- If the
abortSignalfires slightly before thetimeout, which abort reason propagates? - When a timed‑out request is retried, does the retry inherit the original timeout value or restart a fresh timer?
- Should the client expose a configuration to explicitly prioritize
abortSignalovertimeoutor vice versa?