{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/461","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/461/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/461/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/461/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/461","id":63856478,"number":461,"title":"Subscription dies when out of messages.","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":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-23T23:21:00Z","updated_at":"2015-03-25T03:10:36Z","closed_at":null,"body":"When using ``topic.subscription`` to listen to messages via pull, the subscription will (eventually) trigger an error when there are no messages. However, the desired behavior seems to be to just keep trying until messages come in. It appears it's sufficient to just ignore the error for this to continue to work as expected. See example:\r\n\r\n```javascript\r\n  var subscription = topic.subscription(subscriptionName);\r\n  subscription.on('error', function(err) {\r\n    /* This error occurs when there's no new messages.\r\n    Since we want to listen forever, this is a non-error. */\r\n    if (err.code == 400 && err.errors[0].reason == 'failedPrecondition') return;\r\n\r\n    /* 404 means that the subscription hasn't been created. */\r\n    if (err.code == 404) logging.error(\"Pub/sub subscription does not exist.\");\r\n\r\n    throw err;\r\n  });\r\n```"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/comments/85807001","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/461#issuecomment-85807001","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/461","id":85807001,"user":{"login":"tmatsuo","id":41815,"avatar_url":"https://avatars.githubusercontent.com/u/41815?v=3","gravatar_id":"","url":"https://api.github.com/users/tmatsuo","html_url":"https://github.com/tmatsuo","followers_url":"https://api.github.com/users/tmatsuo/followers","following_url":"https://api.github.com/users/tmatsuo/following{/other_user}","gists_url":"https://api.github.com/users/tmatsuo/gists{/gist_id}","starred_url":"https://api.github.com/users/tmatsuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmatsuo/subscriptions","organizations_url":"https://api.github.com/users/tmatsuo/orgs","repos_url":"https://api.github.com/users/tmatsuo/repos","events_url":"https://api.github.com/users/tmatsuo/events{/privacy}","received_events_url":"https://api.github.com/users/tmatsuo/received_events","type":"User","site_admin":false},"created_at":"2015-03-25T03:10:36Z","updated_at":"2015-03-25T03:10:36Z","body":"This behavior should have been changed with the Cloud Pub/Sub API v1beta2. @jonparrott do you know which API version you're using?"}}