{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/2569","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/2569/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/2569/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/2569/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2569","id":253079737,"number":2569,"title":"storage - readStream hangs on long running time pipe","user":{"login":"tomgrossman","id":6324938,"avatar_url":"https://avatars3.githubusercontent.com/u/6324938?v=4","gravatar_id":"","url":"https://api.github.com/users/tomgrossman","html_url":"https://github.com/tomgrossman","followers_url":"https://api.github.com/users/tomgrossman/followers","following_url":"https://api.github.com/users/tomgrossman/following{/other_user}","gists_url":"https://api.github.com/users/tomgrossman/gists{/gist_id}","starred_url":"https://api.github.com/users/tomgrossman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomgrossman/subscriptions","organizations_url":"https://api.github.com/users/tomgrossman/orgs","repos_url":"https://api.github.com/users/tomgrossman/repos","events_url":"https://api.github.com/users/tomgrossman/events{/privacy}","received_events_url":"https://api.github.com/users/tomgrossman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-26T09:49:35Z","updated_at":"2017-08-26T11:33:03Z","closed_at":null,"body":"#### Environment details\r\n  - OS: Ubuntu 16.04\r\n  - Node.js version: 6.11.2\r\n  - npm version: 3.10.10\r\n  - google-cloud-node version: @google-cloud/storage@1.2.1 \r\n\r\nSome more details:\r\nThe file size I'm reproducing the issue on is ~2.3 gb.\r\nThe issue is happening **only** when using **pipe** and **only** when the download speed is below 5 mb\\s.\r\nWhen the download speed is faster or when using `.on('data', (data) => res.write(data))`, there is no problem.\r\n\r\n#### Steps to reproduce\r\n\r\n1. require `@google-cloud/storage`\r\n2. use the following route function, where bucketFile is a pure file instance from the storage lib:\r\n\r\n```javascript\r\nfunction DownloadOva (req, res) {\r\n    console.log(new Date() + ' start');\r\n\r\n    res.on('finish', function () {\r\n        console.log(new Date() + ' finish');\r\n    });\r\n\r\n    let bucketFile = OvaFileHelpers.GetBucketFile('agent_ova/agent.ova');\r\n    bucketFile.createReadStream({validation: false})\r\n        .on('error', (err) => {\r\n            console.log(new Date() + ' error: ' + err.stack);\r\n        })\r\n        .on('response', (streamResponse) => {\r\n            console.log(new Date() + ' streamResponse');\r\n            res.setHeader('Content-Length', streamResponse.headers['content-length']);\r\n            res.setHeader('Content-Type', streamResponse.headers['content-type']);\r\n            res.setHeader('Content-disposition', 'attachment; filename=\"agent_download.ova\"');\r\n        })\r\n        .on('end', () => {\r\n            console.log(new Date() + ' end');\r\n            res.end();\r\n\r\n            return true;\r\n        })\r\n        // .on('data', (data) => {\r\n        //     Response.write(data);\r\n        // })\r\n        .pipe(res);\r\n}\r\n```\r\n3. limit the download speed in chrome using the throttling option in the network developer tools to 5000 kb/s\r\n4. call the route\r\n\r\n**Expected results**:\r\nall console logs outputs should be written to console.\r\n**Actual results**:\r\nThe file is downloaded successfully\r\nthe 'end' and 'finish' events are never called (no console log outputs and doesn't get into the breakpoint). \r\nCan't call the route again until restarting the application\r\n\r\n**more details**:\r\nWhen the download speed is not limited, it works fine (on high speed connection). but some users with low speed connections, faced this issue (that's why I reproduced this issue).\r\nWhen using the commented `.on('data' ...` and commenting out the `pipe`, it also works fine also on slow download.\r\n\r\nIt seems that when the `pipe` takes too long (seems like 3-4 minutes), it looses all the event listening functions and gets hangs even though the download finish successfully on the client side.\r\n\r\nThanks!\r\n"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/comments/325117783","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2569#issuecomment-325117783","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/2569","id":325117783,"user":{"login":"stephenplusplus","id":723048,"avatar_url":"https://avatars0.githubusercontent.com/u/723048?v=4","gravatar_id":"","url":"https://api.github.com/users/stephenplusplus","html_url":"https://github.com/stephenplusplus","followers_url":"https://api.github.com/users/stephenplusplus/followers","following_url":"https://api.github.com/users/stephenplusplus/following{/other_user}","gists_url":"https://api.github.com/users/stephenplusplus/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenplusplus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenplusplus/subscriptions","organizations_url":"https://api.github.com/users/stephenplusplus/orgs","repos_url":"https://api.github.com/users/stephenplusplus/repos","events_url":"https://api.github.com/users/stephenplusplus/events{/privacy}","received_events_url":"https://api.github.com/users/stephenplusplus/received_events","type":"User","site_admin":false},"created_at":"2017-08-26T11:33:03Z","updated_at":"2017-08-26T11:33:03Z","body":"Thank you for reporting. Could you please provide a clonable repo that can reproduce the bug? Since there are other factors at play to load from the browser, I'll need more dependencies and other code to replicate. It's best that I'm using the same dependencies and code that you are."}}
{"actor":{"display_login":"stephenplusplus"}}