Skip to content

Subscription dies when out of messages. #461

Description

@theacodes

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:

  var subscription = topic.subscription(subscriptionName);
  subscription.on('error', function(err) {
    /* This error occurs when there's no new messages.
    Since we want to listen forever, this is a non-error. */
    if (err.code == 400 && err.errors[0].reason == 'failedPrecondition') return;

    /* 404 means that the subscription hasn't been created. */
    if (err.code == 404) logging.error("Pub/sub subscription does not exist.");

    throw err;
  });

Activity

  1. jaredrhine commented on Mar 23, 2015

    @jaredrhine

    Hi, @jonparrott . Are you using auto-ack? If so, a fix is available in #455.

  2. theacodes commented on Mar 24, 2015

    @theacodes
    Author

    Not using autoAck.

  3. tmatsuo commented on Mar 25, 2015

    @tmatsuo
    Contributor

    This behavior should have been changed with the Cloud Pub/Sub API v1beta2. @jonparrott do you know which API version you're using?

  4. theacodes commented on Mar 25, 2015

    @theacodes
    Author

    I was using the version in npm, I tried this out with the master branch here and it doesn't seem to still be an issue. Closing.

  5. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: pubsubIssues related to the Pub/Sub API.
    on May 14, 2015
  6. added this to the Pub/Sub Beta milestone on May 14, 2015
  7. 21 remaining items

  8. added a commit that references this issue on Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions