Axios CancelToken vs AbortController: Which Cancellation Wins?
0 reputation · 14 Oct 2024, 22:30 UTC
Axios Cancellation Interoperability
Goal: determine which cancellation mechanism takes effect first when both a legacy CancelToken and a modern AbortController are attached to a single Axios request. Constraints include Axios v1.5+ deprecation of CancelToken, native AbortController support only in browsers and Node v15+, and the fact that Axios does not automatically link the two signals.
Uncertainty: When both signals are present, does Axios propagate the AbortController signal to the CancelToken, or does the first trigger simply abort the HTTP call while leaving the other pending? How do different environments (browser vs Node) influence this behavior?
Specific questions:
- When a request is cancelled via
AbortControllerafter aCancelTokenhas already been triggered, which cancellation wins? - Is there any automatic propagation of the
AbortControllersignal to theCancelTokenwithin Axios? - What is the expected state of the promise and network connection when both signals are used simultaneously?