Skip to content

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

@logidelic

Description

@logidelic

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions