{"action":"opened","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3055","labels_url":"https://api.github.com/repos/nodejs/node/issues/3055/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3055/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3055/events","html_url":"https://github.com/nodejs/node/issues/3055","id":108196438,"number":3055,"title":"Node fails to download entire (large) file via http/https when `agent: false` is used. Fails on 0.10, 0.12, 4.1.1. ","user":{"login":"trentm","id":46866,"avatar_url":"https://avatars.githubusercontent.com/u/46866?v=3","gravatar_id":"","url":"https://api.github.com/users/trentm","html_url":"https://github.com/trentm","followers_url":"https://api.github.com/users/trentm/followers","following_url":"https://api.github.com/users/trentm/following{/other_user}","gists_url":"https://api.github.com/users/trentm/gists{/gist_id}","starred_url":"https://api.github.com/users/trentm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trentm/subscriptions","organizations_url":"https://api.github.com/users/trentm/orgs","repos_url":"https://api.github.com/users/trentm/repos","events_url":"https://api.github.com/users/trentm/events{/privacy}","received_events_url":"https://api.github.com/users/trentm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-24T19:22:20Z","updated_at":"2015-09-24T19:22:20Z","closed_at":null,"body":"When attempting to download a (largish) file via `https.request` and using `agent: false`, the end of the file will frequently be missing.\r\n\r\nhttps://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.\r\nThere is a sample run with `agent: false` commented out which shows successful downloads a dozen or more times in a row.\r\n\r\nMy 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\r\nThis was me trying to eliminate `.pipe()` usage as a possible cause.\r\n\r\nhttps://gist.github.com/trentm/5d3c4d9dbcb7c3b8dbaa is an equivalent script (and sample runs) using `res.pipe(outStream)`. It fails frequently as well."}}