Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total timeout of API google.pubsub.v1.Publisher exceeded 60000 milliseconds before any response was received. #1906

Open
Kripu77 opened this issue Apr 5, 2024 · 1 comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Kripu77
Copy link

Kripu77 commented Apr 5, 2024

Hi all,

We're encountering below error:

Total timeout of API google.pubsub.v1.Publisher exceeded 60000 milliseconds before any response was received.

Initially, the service successfully publishes messages to a topic without encountering any errors. However, after the application has been running for a while, typically around 1-2 hours, errors begin to manifest. It appears that the pub/sub client retains all the messages in memory after the error occurs, leading to a gradual increase in container memory usage.

Environment details

  • OS: nodejs20-debian12:latest
  • Node.js version: 20
  • npm version: 8.19.2
  • @google-cloud/pubsub version: 4.3.3

Steps to reproduce

Publisher snippet:

async publishEvent(event: Event): Promise<void> {
    try {
      const messageId = await this.topic.publishMessage({
        data: Buffer.from(JSON.stringify(event)),
        attributes: {
          eventType: event.eventType,
          eventVersion: event.eventVersion,
        },
      });
    } catch (error) {
      logger.error(
        `Received error while publishing: ${(error as Error).message}`
      );
    }
  }

Subscirber snippet:

export async function setupPubSubSubscription(
  channel: string,
  callback: (message: string) => void
) {
  const subscription =  pubsub.subscription(channel);

  subscription.on("message", (message) => {
    try {
      callback(message.data.toString());
       message.ack();
    } catch (err) {
      const ackError = err as AckError;
      logger.info({
        error: `Ack for message ${message.id} failed with error: ${ackError.errorCode}`,
      });
    }
  });
  subscription.on("error", (error: Error) => {
    logger.error({
      type: "Pub-Sub Error",
      message: error.message,
      name: error.name,
      stack: error.stack,
    });
  });
  return subscription;
}


@Kripu77 Kripu77 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 5, 2024
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Apr 5, 2024
@Kripu77
Copy link
Author

Kripu77 commented Apr 8, 2024

Hello everyone,

For those who will follow this issue,

We also use @google-cloud/secret-manager in our services, the version we had before any update:"^4.1.1".

Updating @google-cloud/secret-manager to the latest version available as of today, "^5.3.0", successfully resolved the problem.

This upgrade automatically updated the grpc.js version, which I believe to be the root cause and solution to this issue. Alternatively, it might involve adjustments to other internal dependencies utilized by secret-manager and nodejs-pubsub under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant