Axios Request Cancellation: Migration Timing from CancelToken to AbortSignal in v0.22.0+
0 reputation · 19 Dec 2025, 09:16 UTC
Migration Timing and Error Handling Consistency
Axios v0.22.0 introduced signal as the documented cancellation mechanism while retaining the legacy CancelToken API in 1.x releases. Teams maintaining codebases with search-as-you-type or polling logic face a decision: migrate now or continue using CancelToken since both are currently supported.
The constraint is that error shapes differ: 1.x rejects with CanceledError (code: 'ERR_CANCELED') while 0.x rejects with a Cancel instance. Meanwhile axios.isCancel() works across both. Additionally, timeout and AbortSignal.timeout() provide overlapping deadline control but produce different rejection types.
- What criteria should determine the migration timeline for a codebase pinned to axios 0.x that plans to upgrade to 1.x?
- How should error handlers be structured to reliably identify cancellations across both APIs without version-specific error code checks?