Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in 0.19.0: file:/// that always returns a status code 0 now returns an error #2396

Closed
gierschv opened this issue Sep 7, 2019 · 0 comments

Comments

@gierschv
Copy link

gierschv commented Sep 7, 2019

Describe the bug

Since I upgrade axios from 0.18.0 to 0.19.0, the requests made to fetch a local file (file:///) with a relative path return an error: Request failed with status code 0. However the web browser will always return a status code 0 when the request success because there is no HTTP server involved. The XHR readyState is also 4, if there was a network error, I believe this one would probably be 0 as well.

To Reproduce

// In a HTML file like opened at file:///tmp/axios.html for example
axios.get('./file.ttf', {
  responseType: 'arraybuffer',
}).then((resp) => {
  console.log('OK', resp);
}).catch((err) => {
  if (err.request && err.request.readyState === 4) {
     //  The response here should not be treated as an error
  }
  console.log('ERR', err);
});

Expected behavior
The request should success and return the arraybuffer (works with axios 0.18.0).

Environment:

  • Axios Version: 0.19.0
  • OS: iOS 12.4, OSX 10.14.6
  • Browser: Safari
  • Browser Version: 12.1.2
  • Additional Library Versions: None

Additional context/Screenshots
Screenshot 2019-09-07 at 13 26 37
Screenshot 2019-09-07 at 13 31 10

Alanscut added a commit to Alanscut/axios that referenced this issue Oct 17, 2019
Alanscut added a commit to Alanscut/axios that referenced this issue Oct 17, 2019
Alanscut added a commit to Alanscut/axios that referenced this issue Oct 18, 2019
chinesedfan pushed a commit that referenced this issue Mar 23, 2020
* fix issue #2416, #2396

* fix Eslint warn

* Modify judgment conditions

* add unit test

* update unit test

* update unit test
@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants