I am getting duplicate MessageIDs on Google Cloud Pub / Sub. Do note that my payload aka the data field is the same during testing but this should ideally not result in duplicate MessageIDs. Please let me know what's wrong with my code below:
const publish = (topicName, payload) => {
const dataBuffer = Buffer.from(JSON.stringify(payload));
return new Promise((resolve, reject) => {
pubsub
.topic(topicName)
.publisher()
.publish(dataBuffer)
.then(result => {
const messageId = result[0];
console.log(`${messageId} published`);
resolve(messageId);
})
.catch(err => {
console.error(err);
reject(err);
});
});
};