Skip to content

Conversation

@Mostafa-Khairy0
Copy link

@Mostafa-Khairy0 Mostafa-Khairy0 commented Oct 28, 2025

🐞 Bug Fix: Safari TypeError on Fetch Timeout

Axios should throw a proper AxiosError when a request times out, but in Safari the fetch adapter throws a restricted DOM error:

TypeError: The DOMException.message getter can only be used on instances of DOMException

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

TypeError: The DOMException.message getter can only be used on instances of DOMException

🔧 What This PR Fixes

This PR ensures Safari timeout errors thrown by the fetch adapter are converted into proper Axios timeout errors by using:

✔️ Correct error type (AxiosError)
✔️ Proper timeout code (ETIMEDOUT)
✔️ Preserves original error cause
✔️ Full cross-browser consistency
axios.get("https://fakeresponder.com/?sleep=50000", {
  adapter: "fetch",
  timeout: 2000,
});

Environment:
• Safari: 26.0.1
• macOS: 15.6.1
• Axios: 1.13.0
• Adapter: fetch

🔗 Related Issue

Fixes Axios fetch adapter throws TypeError on timeout in Safari #7190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr::fix PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant