Cannot differentiate between cancellation use cases. Only a generic CanceledError is thrown with no abort reason.
Author: bradstiffCreated Feb 24, 2026Updated Jul 2, 2026
Labelstype::breaking
Describe the bug
I am using AbortController to abort requests. I am using two different controllers, one to abort a pending request when a subsequent one is sent (e.g., a search bar), and the other aborts a request after a timeout is reached.
The two controllers are merged into one and the signal is added to the request config.
I need to know when the request is aborted due to timeout, so I am providing a reason when abort is called, e.g., abort('TimeoutError').
But the error that gets thrown is a generic CanceledError. The abort reason is not included.
To Reproduce
try {
const resp = await axios.get('/foo/bar', {
signal: controller.signal
});
// cancel the request
controller.abort('TimeoutError');
}
catch (e) {
if (e.message === 'TimeoutError') {
//logic to handle Timeout differently from other cancellation use cases.
}
}
Axios Version
1.13.5
Additional Libraries
react-native 0.84.0
Source: axios/axios