{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/426","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/426/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/426/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/426/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/pull/426","id":59870160,"number":426,"title":"Emit errors from upstream on file upload","user":{"login":"ryanseys","id":163873,"avatar_url":"https://avatars.githubusercontent.com/u/163873?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanseys","html_url":"https://github.com/ryanseys","followers_url":"https://api.github.com/users/ryanseys/followers","following_url":"https://api.github.com/users/ryanseys/following{/other_user}","gists_url":"https://api.github.com/users/ryanseys/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanseys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanseys/subscriptions","organizations_url":"https://api.github.com/users/ryanseys/orgs","repos_url":"https://api.github.com/users/ryanseys/repos","events_url":"https://api.github.com/users/ryanseys/events{/privacy}","received_events_url":"https://api.github.com/users/ryanseys/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/labels/cla:%20yes","name":"cla: yes","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-04T22:07:14Z","updated_at":"2015-03-05T21:57:11Z","closed_at":"2015-03-05T20:15:23Z","pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/pulls/426","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/pull/426","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-node/pull/426.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-node/pull/426.patch"},"body":"I (think I) have a fix here for #422  but writing the test for it has been troublesome for me, most likely due to my lack of understanding with streams. Hopefully @stephenplusplus can help!\r\n\r\nThe test is passing (all asserts pass and done is called) and then immediately **failing** due to stream.end being called on a stream that (I guess) no longer exists?\r\n\r\nI'm getting the following error when running the test included in this PR and don't know how to fix:\r\n\r\n```\r\n> mocha test/*\r\n\r\n  File\r\n    createWriteStream\r\n      ✓ should re-emit errors\r\n      1) should re-emit errors\r\n\r\n  1 passing (23ms)\r\n  1 failing\r\n\r\n  1) File createWriteStream should re-emit errors:\r\n     Uncaught TypeError: Cannot read property 'ending' of undefined\r\n      at Duplexify.end (/Users/ryanseys/gcloud-node/node_modules/duplexify/index.js:218:27)\r\n      at handleError (/Users/ryanseys/gcloud-node/lib/storage/file.js:1064:12)\r\n      at DestroyableTransform.<anonymous> (/Users/ryanseys/gcloud-node/lib/storage/file.js:992:7)\r\n      at DestroyableTransform.emit (events.js:129:20)\r\n      at Immediate._onImmediate (/Users/ryanseys/gcloud-node/test/storage/file.js:553:18)\r\n      at processImmediate [as _immediateCallback] (timers.js:358:17)\r\n```"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/comments/77460855","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/pull/426#issuecomment-77460855","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/426","id":77460855,"user":{"login":"teddybearz","id":4357264,"avatar_url":"https://avatars.githubusercontent.com/u/4357264?v=3","gravatar_id":"","url":"https://api.github.com/users/teddybearz","html_url":"https://github.com/teddybearz","followers_url":"https://api.github.com/users/teddybearz/followers","following_url":"https://api.github.com/users/teddybearz/following{/other_user}","gists_url":"https://api.github.com/users/teddybearz/gists{/gist_id}","starred_url":"https://api.github.com/users/teddybearz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teddybearz/subscriptions","organizations_url":"https://api.github.com/users/teddybearz/orgs","repos_url":"https://api.github.com/users/teddybearz/repos","events_url":"https://api.github.com/users/teddybearz/events{/privacy}","received_events_url":"https://api.github.com/users/teddybearz/received_events","type":"User","site_admin":false},"created_at":"2015-03-05T21:57:11Z","updated_at":"2015-03-05T21:57:11Z","body":"I wonder in real network scenario (not just the test mock environment), it is possible that there will be one error event and one complete event+error being emitted back to back with error code all equals to 404 or 499-600. If it happens, the handleError() will be called twice and startUpload() resumeUpload() will be called twice."}}