Skip to content

Axios fetch adapter throws TypeError on timeout in Safari #7190

@carlosc-dev

Description

@carlosc-dev

Describe the bug

On a request timeout Axios should throw an AxiosError, but when using the fetch adapter in Safari a TypeError: The DOMException.message getter can only be used on instances of DOMException is thrown.

Image

userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0.1 Safari/605.1.15

To Reproduce

  1. Use Safari
  2. Make a request using the fetch adapter and make it timeout
  3. On timeout it throws a TypeError: The DOMException.message getter can only be used on instances of DOMException

Sandbox with a request that always ends in timeout: https://codesandbox.io/p/sandbox/zkm26r

Code snippet

axios.get("https://fakeresponder.com/?sleep=50000", { adapter: "fetch", timeout: 2000 });

axios.get("https://api.example.com", { adapter: "fetch", timeout: 1 });

Expected behavior

Should throw an AxiosError with the timeout info, like the default adapter:

{
  message: "timeout 2000 of ms exceeded",
  code:  "ETIMEDOUT",
  name: "AxiosError"
}

Axios Version

1.13.0

Adapter Version

fetch

Browser

Safari

Browser Version

26.0.1

Node.js Version

No response

OS

OSX 15.6.1

Additional Library Versions

none

Additional context/Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions