I am trying to implement this retry logic + send messages by batch
https://cloud.google.com/pubsub/docs/samples/pubsub-publisher-retry-settings#pubsub_publisher_retry_settings-nodejs_typescript
But I see an error on the client.publish
call. You have passed an invalid argument to the service (argument={{projectId}})
export const instance = new PubSub()
export const pubSubClient = new v1.PublisherClient();
export const psaWorkerTopic = instance.topic(
MAIN.PSA_WORKER_PUBSUB_TOPIC_NAME,
{ messageOrdering: true }
)
const request = {
topic: psaWorkerTopic.name,
messages: messages.map((message) => ({
data: Buffer.from(JSON.stringify(message.data)),
orderingKey: message.orderingKey,
})),
};
const [response] = await pubSubClient.publish(request, CLIENT_PUBLISH_OPTIONS);
But at the same time psaWorkerTopic.publishMessage(message)
works without any problems.
What is wrong and why PublisherClient
is not parsing projctId from env?