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

When transfer encoding is chunked, GOT sometimes does not download full content #1591

Closed
2 tasks done
adityapatadia opened this issue Jan 28, 2021 · 3 comments
Closed
2 tasks done

Comments

@adityapatadia
Copy link

Describe the bug

  • Node.js version: 14.15.1. GOT latest.
  • OS & version: Ubuntu 20.04

Actual behavior

When downloading content which does not have content-length header, i.e. chunked transfer, GOT sometimes does not download full content when responseType: 'buffer' is set. One example URL is here: https://cdn.sentinelassam.com/h-upload/2021/01/28/193125-whatsapp-image-2021-01-28-at-112922-am.webp

Expected behavior

It should download full content.

Code to reproduce

Not able to re-produce reliably as it happens only sometimes. I am not sure under which conditions but it certainly happens.

Checklist

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

There unfortunately no actionable info here. Would you be able to try on the latest Node.js 15 release?

@adityapatadia
Copy link
Author

We could solve it by putting this code

let lengthMatches = true;
if (response.headers && response.headers['content-length']) {
    lengthMatches = parseInt(response.headers['content-length']) == response.body.byteLength;
  }

if(response.body.byteLength != 0 && lengthMatches && response.complete){
   //everything looks okay....
  }

May be this can give you some idea? We will not be able to try on Node 15 because this issue is not reproducible on local machine and can only be produced when there is very high load. We will still give you info if we find something.

@szmarczak szmarczak mentioned this issue Mar 21, 2021
71 tasks
@szmarczak szmarczak mentioned this issue Apr 13, 2021
13 tasks
@szmarczak
Copy link
Collaborator

Closing in favor of #1462

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

3 participants