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

Issue with downloading files larger than a few mbs on Chrome specifically #6358

Open
asynch8 opened this issue Apr 16, 2024 · 4 comments
Open

Comments

@asynch8
Copy link

asynch8 commented Apr 16, 2024

Describe the bug

I'm fetching a files using Axios 1.6.8 and Chrome, and when I try to fetch a 'larger'(<16mb) zip-file within Chrome, it fails saying network error.
The backend responds 200, both according to the backend itself and to the browser, and even Axios agrees, shown by this error:

net::ERR_FAILED 200 (OK)

The rest of the stacktrace contains nothing really interesting.

Switching to Firefox fixes the issue, and so does replacing Axios with native fetch.

I've also tried it in Vue and React separately, so probably not a framework issue.

To Reproduce

https://codesandbox.io/p/sandbox/nice-tristan-vqcwnm
I've provided some description and ways to reproduce in this sandbox. Although, I want to note that when I sent this codesandbox to a friend of mine to run on his machine, and he didn't see the same issue I am seeing. He's running W11, Chrome 123.0.6312.122

Code snippet

// Code I was running
axios.get(url, { responseType: 'blob', headers: {
        ...
      } })
  .then(async response => {
    let blob = new Blob([response.data], { type: contentType })
    
    const link = document.createElement('a')
    link.href = URL.createObjectURL(blob)
    console.log({ name })
    link.download = name;
    link.click()
    URL.revokeObjectURL(link.href)
  }).catch((error) => {
    console.error(error);
  })

 
//And here's the code I replaced it with:
 fetch(url, {
    headers: {
      ...
    }
  })
  .then(response => response.blob())
  .then(async blob => {
    blob = new Blob([blob], { type: contentType })
    
    const link = document.createElement('a')
    link.href = URL.createObjectURL(blob)
    link.download = name;
    link.click()
    URL.revokeObjectURL(link.href)
  }).catch((error) => {
    console.error(error);
  })

Expected behavior

The expected behavior is for Axios to successfully download my file and not throw an internal error.

Axios Version

1.6.8

Adapter Version

No response

Browser

Chrome

Browser Version

123.0.6312.123

Node.js Version

No response

OS

Windows 10

Additional Library Versions

React,
Vue3

Additional context/Screenshots

No response

@asynch8 asynch8 changed the title Issue with downloading larger files on Chrome specifically Issue with downloading files larger than a few mbs on Chrome specifically Apr 16, 2024
@freegithuber
Copy link

是不是你的文件下载目录空间太小了,同样的问题我清理下载目录磁盘空间后解决了。

@asynch8
Copy link
Author

asynch8 commented Apr 24, 2024

@freegithuber Translated comment: It's not like your file download directory space is too small, the same problem is solved after I clear the download directory disk space'
(I've google translated the comment and put it in a response here.)

No, I do not believe that is the case, for the following reasons:

  • All my disks have much more than 16mb available, at the smallest 3gb, and biggest 4tb available
  • I didn't remove any files in between downloading each of the testcases
  • It consistently fails on the 'Axios ~16mb' case, while Fetch is working fine for the same file.

@aymanson
Copy link

Hi @asynch8 , wanna see if you are running chrome under windows when you encounter such issue. Seems recently I also encounter such problem. However, the download is OK under MacOS chrome. So I am still trying to figure out what happened.

@asynch8
Copy link
Author

asynch8 commented Apr 25, 2024

@aymanson Correct, I was also running windows, and it does succeed on my OSX machine.
However, now that I'm testing out the codesandbox on the windows machine again, I do seem to be able to succeed... Not sure what has changed or why it's working now, but it is.
Guess it might've been something temporary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants