Skip to content

axios with fetch adapter does not handle network error in safari #6766

@solo5star

Description

@solo5star

Describe the bug

When network request failed, axios with fetch adapter should throws AxiosError (code=ERR_NETWORK, message=Network Error)

but TypeError: Load failed thrown in Safari.

To Reproduce

Using Safari browser (my user agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15)

and try to fetch where the network request might fail.

you can simply reproduce using esm.sh:

await import('https://esm.sh/axios').then(({ default: axios }) => axios('https://just-fetch-failed', { adapter: 'fetch' }))

Code snippet

import axios from 'axios'

await axios('https://just-fetch-failed', { adapter: 'fetch' })

Expected behavior

Should throws Axios Error: Network Failed

But TypeError: Load failed thrown.

Image

Axios Version

1.7.9

Adapter Version

fetch adapter

Browser

Safari

Browser Version

18.2(20620.1.16.11.8)

Node.js Version

No response

OS

OSX 15.2

Additional Library Versions

nothing

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