{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/436","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/436/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/436/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/436/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/436","id":60548539,"number":436,"title":"File write stream does not error when writing to a file in a non-existent bucket","user":{"login":"jonparrott","id":250995,"avatar_url":"https://avatars.githubusercontent.com/u/250995?v=3","gravatar_id":"","url":"https://api.github.com/users/jonparrott","html_url":"https://github.com/jonparrott","followers_url":"https://api.github.com/users/jonparrott/followers","following_url":"https://api.github.com/users/jonparrott/following{/other_user}","gists_url":"https://api.github.com/users/jonparrott/gists{/gist_id}","starred_url":"https://api.github.com/users/jonparrott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonparrott/subscriptions","organizations_url":"https://api.github.com/users/jonparrott/orgs","repos_url":"https://api.github.com/users/jonparrott/repos","events_url":"https://api.github.com/users/jonparrott/events{/privacy}","received_events_url":"https://api.github.com/users/jonparrott/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/labels/storage","name":"storage","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/milestones/6","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/milestones/Storage%20Stable","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/milestones/6/labels","id":961392,"number":6,"title":"Storage Stable","description":"","creator":{"login":"jgeewax","id":112928,"avatar_url":"https://avatars.githubusercontent.com/u/112928?v=3","gravatar_id":"","url":"https://api.github.com/users/jgeewax","html_url":"https://github.com/jgeewax","followers_url":"https://api.github.com/users/jgeewax/followers","following_url":"https://api.github.com/users/jgeewax/following{/other_user}","gists_url":"https://api.github.com/users/jgeewax/gists{/gist_id}","starred_url":"https://api.github.com/users/jgeewax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgeewax/subscriptions","organizations_url":"https://api.github.com/users/jgeewax/orgs","repos_url":"https://api.github.com/users/jgeewax/repos","events_url":"https://api.github.com/users/jgeewax/events{/privacy}","received_events_url":"https://api.github.com/users/jgeewax/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":50,"state":"open","created_at":"2015-02-02T13:30:45Z","updated_at":"2015-03-10T19:10:56Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-03-10T18:42:50Z","updated_at":"2015-03-10T19:30:30Z","closed_at":null,"body":"When using file.createWriteStream when the file was created on a non-existent bucket, the stream does not error and essentially acts as if everything is fine. The only indication of error is the fact that no file is uploaded.\r\n\r\nIn the example below, one would expect the error event to trigger:\r\n```javascript\r\nvar gcloud = require('gcloud');\r\n\r\nvar storage = gcloud.storage({\r\n  keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS,\r\n  projectId: process.env.GCLOUD_PROJECT_ID\r\n})\r\n\r\nvar bucket = storage.bucket('this-bucket-does-not-exist');\r\n\r\nvar file = bucket.file('file.ext');\r\nvar stream = file.createWriteStream();\r\n\r\nstream.on('error', function(){ console.log('Error'); });\r\nstream.on('finish', function(){ console.log('Done'); });\r\n\r\nstream.write('data');\r\nstream.end();\r\n```"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/comments/78129552","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/436#issuecomment-78129552","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/436","id":78129552,"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},"created_at":"2015-03-10T19:30:30Z","updated_at":"2015-03-10T19:30:30Z","body":"This is caused by [`handleError`](https://github.com/GoogleCloudPlatform/gcloud-node/blob/7fb3c1756cc3622bce6776ca00e77d4ea1e3687c/lib/storage/file.js#L1110) being used for **all the things** and the error is a 404 (bucket not found), which no amount of `startUpload` will solve."}}