I've got a function that create topics and subscriptions when my server boots.
The problem is that I can't create subscription linked to a newly created topic, the Google PubSub server throws a NOT FOUND error.
I've even added a 20 second timeout after the topic creation but nothing changed T_T
export async function init() {
// promises.topics is an array of promises
const topics = await Promise.all(promises.topics);
console.log('YEAH !!! TOPIC IS GOOD !', topics);
// That works ! And it is created in my remote google PubSub
await timeout(20000);
console.log('Lets Check if it exists !!!');
// promises.getTopics is an array of :
// getTopics.push(pubSubClient.topic(topic.name).get());
// That throws a NOT FOUND
const get = await Promise.all(promises.getTopics);
// Failes because Topics are not found
const subscriptions = await Promise.all(promises.subscriptions);
}
When I check in the Google logs, the created topic is created AFTER the subscriptions oO
My Promise array inject first topics Then the subscriptions promises.
When adding a retry function that try again 10 times every 2 second, it don't work either.
It's no even showing in google logs, I think they have a cache ton their API that just return newly processed data without re-trying it.
Do you have an idea ?
Thanks :)
SUBSCRIPTION ERROR :
EDIT :
I Managed to fix the problem by adding a timeout('2000') after pushing the topic promise creation in my promise array.

