Skip to content

Subscription dies when out of messages. #461

@theacodes

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;
  });

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