-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
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
Labels
No labels