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

Download Progress Bar Goes Straight to 100% #59

Open
dsanders11 opened this issue Jan 20, 2023 · 3 comments
Open

Download Progress Bar Goes Straight to 100% #59

dsanders11 opened this issue Jan 20, 2023 · 3 comments
Labels
area:versions 🪲 bug Something isn't working 🌿 upstream Issues related to Upstream dependencies

Comments

@dsanders11
Copy link
Member

When displaying download progress, it goes straight to "🏁 downloading 23.0.0-beta.3 - 100%"

Doing some logging, it looks like the progress percentages it receives are 0, 1, 0, and then actual fractional values. When 1 is received it sets progress to 100% and considers it done and doesn't display the real progress updates.

Issue is upstream either in @electron/get or got.

@dsanders11 dsanders11 added the 🪲 bug Something isn't working label Jan 20, 2023
@dsanders11 dsanders11 added the 🌿 upstream Issues related to Upstream dependencies label Feb 12, 2023
@marfgold1
Copy link

marfgold1 commented Mar 30, 2024

The issue is in got.stream. Here's the following breakdown:

  1. Progress received total (as provided by the Content-Length) as undefined at first, which makes the percent comes to 0.
  2. Progress received total of 0 with transferred (total downloaded size) equal to 0 too, which makes the percent to be 1.
  3. Progress eventually receive the correct total, which makes the percent goes back to 0 again, then actual fractional values.

I'm not sure if that was intended in got.stream (going to investigate at this moment), but one suggestion that I can think of is changing @electron/get at GotDownloader.download such that when listening to downloadProgress of the got.stream, we should return early if !progress.total (or to be exact, equal to 0 or undefined), which ignores the first and second case.

@marfgold1
Copy link

I think I found the culprit, it's because got.stream report downloadProgress when redirect. The GitHub artifacts redirect user to the actual content when someone downloading the release artifact file.
For example, if we want to download electron-v29.1.5-win32-x64, it will hit an HTTP/1.1 302 Found and redirect us to domain objects.githubusercontent.com, the actual content, with content-length of 0. got.stream report the before redirect content-length as undefined first, then 0 when it ends the redirect, just before requesting the actual content.
image

This behavior also exist in another URL which needs redirects, for example http://youtube.com will redirect to https://youtube.com and finally redirect to https://www.youtube.com.
image

A simple fix is checking total that I propose before, but I'm not sure if we should forward it to got.

@botPuneet
Copy link

botPuneet commented Apr 7, 2024

hey @dsanders11 sir, i made a pr related to this issue i think it is due to we dont consider the fraction numbers. Pls review it and i am open for any feedback. #pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:versions 🪲 bug Something isn't working 🌿 upstream Issues related to Upstream dependencies
Projects
None yet
Development

No branches or pull requests

3 participants