fix(fetch): normalize Safari timeout errors to AxiosError#7191
fix(fetch): normalize Safari timeout errors to AxiosError#7191Mostafa-Khairy0 wants to merge 7 commits intoaxios:v1.xfrom
Conversation
This comment was marked as spam.
This comment was marked as spam.
1 similar comment
This comment was marked as spam.
This comment was marked as spam.
The previous catch fired on any DOMException or AbortError, which reclassified user-initiated cancellations as ETIMEDOUT. Switch the discriminator to composedSignal.reason being the AxiosError(ETIMEDOUT) injected by composeSignals so only true timeouts take the timeout path. Drop the bare DOMException reference (would ReferenceError outside browsers/modern Node), preserve cause for debugging, and align the message text with composeSignals and the http adapter. Add tests covering: real timeout produces AxiosError(ETIMEDOUT); manual abort is not misclassified (regression); Safari simulation where fetch rejects with a generic DOMException still surfaces ETIMEDOUT. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I tried to push a follow-up commit here to keep this PR as the landing path, but GitHub denied write access to I opened #10806 as a fallback based on this PR’s work, with commit co-author credit for @Mostafa-Khairy0 and @jasonsaayman. It keeps the If maintainers prefer this PR to remain the landing PR, the patch from #10806 can be applied here directly. |
Based on the work in axios#7191. Co-authored-by: Mostafa-Khairy0 <mostafakhairy0305@gmail.com> Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
|
Hey @Mostafa-Khairy0, thanks again for digging into this. The Safari abort behaviour is genuinely weird and you nailed the underlying cause: the fix has to come from the composed signal's reason, not from Quick context on what's happening with this PR. After the review thread we wanted to extend the same approach to also cover user cancellations (so A couple of small things in #10806 worth calling out, in case you're curious:
Closing this in favour of #10806. The credit there points back here, and the original framing of the bug is what unblocked the fix — appreciate you sticking with it. |
Based on the work in #7191. Co-authored-by: Mostafa-Khairy0 <mostafakhairy0305@gmail.com> Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
🐞 Bug Fix: Safari TypeError on Fetch Timeout
Axios should throw a proper
AxiosErrorwhen a request times out, but in Safari the fetch adapter throws a restricted DOM error:This causes Axios to incorrectly classify the timeout as a generic network failure instead of a timeout error.
✅ Expected Behavior
{ "message": "timeout 2000 of ms exceeded", "code": "ETIMEDOUT", "name": "AxiosError" }❌ Actual Safari Behavior
🔧 What This PR Fixes
This PR ensures Safari timeout errors thrown by the fetch adapter are converted into proper Axios timeout errors by using:
Environment:
• Safari: 26.0.1
• macOS: 15.6.1
• Axios: 1.13.0
• Adapter: fetch
🔗 Related Issue