-
Notifications
You must be signed in to change notification settings - Fork 710
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
Downloading files with urllib results in missing KB #1411
Comments
What platform are you seeing these partial downloads occurring on? Presumably its not macOS where we download using the external curl tool? Is it linux or windows? Sadly the I'm curious how you think the urllib implementation could be failing? I bug in urllib itself seems highly unlikely. And the fact that nobody else has reported this issue in over a decade also seems odd. I think its worth investigating furthur. |
I am using Windows. Due to well-known reasons, Chinese developers often need to use proxies to accelerate access. It's not that urllib has a 'bug', but it seems less capable of handling less stable network environments. That's why I switched to the requests library, which gave me more consistent results. As for why others haven't reported this issue, there could be various reasons. Many might simply choose to download files manually rather than addressing the root cause of the problem. Also, even when using a proxy, it doesn't necessarily mean the network is unstable - at least my friends can execute the script normally. I hope this additional context helps explain the situation. I completely understand the importance of maintaining high portability for the script. Your point about
This way, we maintain portability while offering a more robust solution for those who need it. |
I would like to understand exactly what the problem is with the urllib implementation before making any change here. Is the problem consistent for you? Perhaps we can start by adding some assertions here? Presumably we should never be returning success if not all the bytes were transferred? |
I encountered an issue while using the
urllib
version of the download function. Specifically, the downloaded files consistently missed a few KB of data, leading to incomplete downloads.To address this, I rewrote the download function using the
requests
library. The rewritten version successfully resolves the issue, consistently downloading complete files without missing data.Given this improvement, I suggest that the repository prioritize the use of the
requests
library for downloading files. Therequests
library offers a more robust and user-friendly API, and in my experience, it handles file downloads more reliably thanurllib
. We can useurllib
only ifrequests
is unavailable or unsuitable for certain edge cases.Below is the code I used to replace the original
urllib
implementation. I hope it helps and can be integrated into the repository for a more reliable file download process.Additionally, the changes I made were based on the emsdk dependency of the skia
chrome/m127
branch, requiring further improvements to accommodate the latest emsdk.The text was updated successfully, but these errors were encountered: