Skip to content

Node fails to download entire (large) file via http/https when agent: false is used. Fails on 0.10, 0.12, 4.1.1.  #3055

Closed
@trentm

Description

@trentm

When attempting to download a (largish) file via https.request and using agent: false, the end of the file will frequently be missing.

https://gist.github.com/trentm/80409ded30b4e0418e9c has a demo script and sample runs showing it failing on node 0.10.40 and node 4.1.1. In my experience I get a failure between 10% - 80% of the time.
There is a sample run with agent: false commented out which shows successful downloads a dozen or more times in a row.

My sample script just does manual writing of 'data' chunks from the res (response) to a file (fs.createWriteStream): https://gist.github.com/trentm/80409ded30b4e0418e9c#file-download-sans-agent-js-L83-L86
This was me trying to eliminate .pipe() usage as a possible cause.

https://gist.github.com/trentm/5d3c4d9dbcb7c3b8dbaa is an equivalent script (and sample runs) using res.pipe(outStream). It fails frequently as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions