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

Stream report downloadProgress when redirects #2343

Open
2 tasks done
marfgold1 opened this issue Mar 31, 2024 · 1 comment
Open
2 tasks done

Stream report downloadProgress when redirects #2343

marfgold1 opened this issue Mar 31, 2024 · 1 comment

Comments

@marfgold1
Copy link

marfgold1 commented Mar 31, 2024

Describe the bug

In got.stream, downloadProgress fired when redirects happens. Every time redirect happens, the progress report from 0 (with total of content-length, undefined if not any) to 1 instantly (with total of 0). Related issue: electron/fiddle-core#59

  • Node.js version: v20.10.0
  • OS & version: Windows 11 23H2 (22631.3296)

Actual behavior

downloadProgress triggered every time redirect happens. This makes the progress percent from 0 to 1 and repeat until response.

Expected behavior

downloadProgress should report when it only receive a proper response, not redirect.

Code to reproduce

const { default: got } = require("got");
const dSteram = got.stream('https://github.com/electron/electron/releases/download/v29.1.5/electron-v29.1.5-win32-x64.zip');
dSteram.on('request', (req) => console.log("\n\nREQUEST ===========================", req.path));
dSteram.on('redirect', (req, resp) => {
    console.log('====== REDIRECT ======');
    console.log('FROM: ', req.url);
    console.log('TO: ', resp.url.href);
});
dSteram.on('response', (response) => {
    console.log('======= RESPONSE =======');
    console.log('URL: ', response.url);
});
dSteram.on('downloadProgress', (progress) => {
    console.log('====== PROGRESS ======');
    console.log(progress);
});

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
@jdesboeufs
Copy link

Same here.
A simple work-around is to wait for response event and check its status.

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

2 participants