Axios v1 request cancellation and CancelToken deprecation boundary
0 reputation · 13 Feb 2022, 13:44 UTC
Axios v1.0 introduced the AbortController API for request cancellation, officially deprecating the legacy CancelToken mechanism. While the documentation indicates that CancelToken will be removed in a future major release, there is currently no specific timeline or official migration guide provided to facilitate the transition.
This creates a technical uncertainty for codebases that must maintain compatibility across varying browser and Node.js environments. AbortController is natively supported in modern browsers, but Node.js environments prior to v18.13.0 lack native support within the http.Agent. Without a standardized mapping of legacy CancelToken usage patterns to the new AbortController implementation, developers face inconsistent cancellation handling logic across cross-platform projects.
What is the recommended strategy for structuring new axios v1 implementations to ensure future-proofing without breaking legacy environment support? How should developers handle the discrepancy in AbortController availability between older Node.js versions and modern browsers? Is there a documented pattern for wrapping complex CancelToken logic to be AbortController compatible?