googleapis/nodejs-pubsub

Misleading error message

hspak opened this issue · 1 comments

hspak commented

Environment details

  • OS: Cloud Run Service
  • Node.js version: 18.16.0
  • npm version: 9.5.1
  • @google-cloud/pubsub version: 3.5.0

Steps to reproduce

  1. Publish messages with orderingKey set.
  2. Wait for a message to fail.
  3. All subsequent messages fail, but with a timeout error message (way before the timeout).

I suspect that we are running into this behavior, but the error message does not seem indicative of that:

nodejs-pubsub/src/topic.ts

Lines 861 to 887 in 6c38e7b

/**
* In the event that the client fails to publish an ordered message, all
* subsequent publish calls using the same ordering key will fail. Calling
* this method will disregard the publish failure, allowing the supplied
* ordering key to be used again in the future.
*
* @param {string} orderingKey The ordering key in question.
*
* @example
* ```
* const {PubSub} = require('@google-cloud/pubsub');
* const pubsub = new PubSub();
* const topic = pubsub.topic('my-topic', {messageOrdering: true});
*
* const orderingKey = 'foo';
* const data = Buffer.from('Hello, order!');
*
* topic.publishMessage({data, orderingKey}, err => {
* if (err) {
* topic.resumePublishing(orderingKey);
* }
* });
* ```
*/
resumePublishing(orderingKey: string): void {
this.publisher.resumePublishing(orderingKey);
}

I'm sorry I don't have a good, small reproduction case but here's effectively the code being run:

import { PubSub, Topic as PubSubTopic } from '@google-cloud/pubsub';

const pubsub = new PubSub(clientConfig);
const topic = pubsub.topic('TopicName', {
  messageOrdering: true,
  batching: {
    maxMessages: 100,
    maxMilliseconds: 250,
  },
};

await topic.publishMessage({
  data: somePayload,
  attributes: someAttrs,
  orderingKey: 'myOrderingKey'
});                                        

Here's a timestamp from Cloud Logging showing that the publish failed due to a timeout after 50 seconds only after less than a second of running:
Screenshot 2023-08-07 at 2 27 57 PM

I believe the error message is misleading and incorrect here.

@hspak Thanks for the issue. It does look like there's something odd going on there with the error message.