{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1163","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1163/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1163/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1163/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/1163","id":140429668,"number":1163,"title":"Unhandled stream error in pipe","user":{"login":"JustinBeckwith","id":534619,"avatar_url":"https://avatars.githubusercontent.com/u/534619?v=3","gravatar_id":"","url":"https://api.github.com/users/JustinBeckwith","html_url":"https://github.com/JustinBeckwith","followers_url":"https://api.github.com/users/JustinBeckwith/followers","following_url":"https://api.github.com/users/JustinBeckwith/following{/other_user}","gists_url":"https://api.github.com/users/JustinBeckwith/gists{/gist_id}","starred_url":"https://api.github.com/users/JustinBeckwith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustinBeckwith/subscriptions","organizations_url":"https://api.github.com/users/JustinBeckwith/orgs","repos_url":"https://api.github.com/users/JustinBeckwith/repos","events_url":"https://api.github.com/users/JustinBeckwith/events{/privacy}","received_events_url":"https://api.github.com/users/JustinBeckwith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-13T00:09:33Z","updated_at":"2016-03-13T00:14:05Z","closed_at":null,"body":"**Disclaimer**: this may be a gcloud-node problem or a GCS problem - not really sure.  \r\n\r\nI'm working on a project where I download a lot of images and then upload them in parallel to GCS.  When the number of simultaneous operations against GCS trend towards 100-200, I get a bunch of random connection reset failures on /some/ requests:\r\n\r\n\t[Error: Could not authenticate request read ECONNRESET]\r\n\r\nWhen I trend towards 300 simultaneous operations, the app just crashes outright with this error:\r\n\r\n```\r\nstream.js:74\r\n      throw er; // Unhandled stream error in pipe.\r\n      ^\r\n\r\nError: socket hang up\r\n    at createHangUpError (_http_client.js:200:15)\r\n    at Socket.socketOnEnd (_http_client.js:292:23)\r\n    at emitNone (events.js:72:20)\r\n    at Socket.emit (events.js:166:7)\r\n    at endReadableNT (_stream_readable.js:905:12)\r\n    at nextTickCallbackWith2Args (node.js:442:9)\r\n    at process._tickCallback (node.js:356:17)\r\n```\r\n\r\nI boiled this down to a fairly small repro:\r\n\r\n```js\r\nvar request = require('request');\r\nvar uuid = require('node-uuid');\r\nvar util = require('util');\r\nvar gcloud = require('gcloud')({\r\n  projectId: 'YOUR PROJECT ID',\r\n  keyFilename: 'keyfile.json'\r\n});\r\n\r\nvar storage = gcloud.storage();\r\nvar bucket = storage.bucket('scaletest');\r\nvar count = 0;\r\n\r\nfor (var i=0; i<200; i++) {\r\n  (function() {\r\n    var idx = count++;\r\n    var name = uuid.v4();\r\n    var file = bucket.file(name);\r\n    console.log('Request #' + idx);\r\n    request(\"http://jbeckwith.com/images/head.png\")\r\n      .pipe(file.createWriteStream())\r\n      .on('finish', () => {\r\n        console.log(\"Success! #\" + idx);\r\n        file.delete();\r\n      }).on('error', (err) => {\r\n        console.error(\"Fail! #\" + idx + \"\\n\\t\" + util.inspect(err));\r\n      });\r\n  })();\r\n}\r\n\r\nsetInterval(()=>{},1000);\r\n```\r\n\r\nAnd a `package.json`:\r\n\r\n```json\r\n{\r\n  \"name\": \"maxconn\",\r\n  \"version\": \"1.0.0\",\r\n  \"description\": \"\",\r\n  \"main\": \"test.js\",\r\n  \"scripts\": {\r\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\r\n  },\r\n  \"author\": \"\",\r\n  \"license\": \"ISC\",\r\n  \"dependencies\": {\r\n    \"gcloud\": \"^0.29.0\",\r\n    \"node-uuid\": \"^1.4.7\",\r\n    \"request\": \"^2.69.0\"\r\n  }\r\n}\r\n```\r\n\r\nI suspect there's an endpoint in GCP throttling the number of active connections from a single client, and I'm bumping up on that limit.  "},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/comments/195837468","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/1163#issuecomment-195837468","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1163","id":195837468,"user":{"login":"JustinBeckwith","id":534619,"avatar_url":"https://avatars.githubusercontent.com/u/534619?v=3","gravatar_id":"","url":"https://api.github.com/users/JustinBeckwith","html_url":"https://github.com/JustinBeckwith","followers_url":"https://api.github.com/users/JustinBeckwith/followers","following_url":"https://api.github.com/users/JustinBeckwith/following{/other_user}","gists_url":"https://api.github.com/users/JustinBeckwith/gists{/gist_id}","starred_url":"https://api.github.com/users/JustinBeckwith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustinBeckwith/subscriptions","organizations_url":"https://api.github.com/users/JustinBeckwith/orgs","repos_url":"https://api.github.com/users/JustinBeckwith/repos","events_url":"https://api.github.com/users/JustinBeckwith/events{/privacy}","received_events_url":"https://api.github.com/users/JustinBeckwith/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T00:14:05Z","updated_at":"2016-03-13T00:14:05Z","body":"Another thing to throw out there - in a more complex scenario where I'm making other calls to pub/sub and cloud vision, I noticed that other connections start to fail too - not just storage.   "}}