superagent icon indicating copy to clipboard operation
superagent copied to clipboard

Node Download Progress Never Fires

Open allout58 opened this issue 5 years ago • 1 comments

I'm trying to use the .on('progress', cb) method for a download in my Node application, but the callback function is never called. For uploads, .on('progress', cb) works just fine.

Relevant versions:

  • node: 12.14.1
  • superagent: 6.1.0
  • typescript: 4.0.5
  • ts-node: 9.0.0

Download example (does not work):

agent()
  .get(downloadUrl)
  .maxResponseSize(this.maxDownloadSize ?? 200_000_000)
  .on('progress', ev => {
    console.log('Progress: ', ev.loaded);
   })
  .then(r => {
    console.log("Response body: ', r.body);
  });

Upload example (works):

agent()
  .post(uploadUrl)
  .attach('file1', bufferToUpload, {filename: 'thing1.zip', contentType: 'application/zip'})
  .on('progress', ev => {
    console.log('Progress: ', ev.loaded);
  })
  .then(r => {
    console.log("Response body: ', r.body);
  });

allout58 avatar Nov 04 '20 17:11 allout58

I met the same problem.

bear-boss avatar Dec 09 '20 13:12 bear-boss