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

End event called even though there was a download error #41

Open
logidelic opened this issue Apr 18, 2018 · 1 comment
Open

End event called even though there was a download error #41

logidelic opened this issue Apr 18, 2018 · 1 comment

Comments

@logidelic
Copy link

I am observing the following behavior on a particular (unreliable) network. progress gets executed a few times before the download fails. However, instead of the error event being called, the end event is called:

//...
.then(function(){return new Promise(function(resolve, reject) {
    progress(request(MY_URL), {throttle:2000, delay:500})
    .on('progress', function (state) {
        console.log('Downloading ('+(state.percent*100).toFixed(1)+'%)...');
    })
    .on('error', function(err) {
        console.log('Error downloading.');
    })
    .on('end', function () {
        setTimeout(resolve, 100);
    })
    .pipe(fs.createWriteStream(MY_FNAME));
})})
.then(function(){
    console.log('Success!')
//...

Here I see :

Downloading (0.1%)...
Downloading (0.5%)...
Downloading (0.9%)...
Success!

I then verify that the file size is a small fraction of the total download. Notice how the log line "Error downloading" never gets displayed and instead see Success (i.e. 'end' event).

@BlackHole1
Copy link

Hi, can you solve it?

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