-
Notifications
You must be signed in to change notification settings - Fork 237
Description
So here is a list of pictures with explanatory text to it. My plea is in the bottom :D
These three images explains the issue and outcome of what I struggle with understanding why is happening. Using the same local pubsub emulator, with two different methods of sending, results in different outcome.



The one that I think is proper also outputs this line as the context: 
The attempt that gives the proper result looks like this, directly copy paste from here: https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/master/docs/events.md

The effort that results in the wrong result is through code and this is the following code.
const publish = async (topicName, data) => {
try {
const messageId = uuid();
const customAttributes = {
messageId,
};
const payload = Buffer.from(JSON.stringify(data));
const topic = await getTopic(topicName);
const pubsubMessageId = await topic.publish(payload, customAttributes);
logger.info(`Message ${pubsubMessageId} published. Unique payload ID: ${messageId}`);
} catch (err) {
logger.error(err.message, { status: err.status, err: err, stack: err.stack, });
throw err;
}
};
const getTopic = async (name) => {
try {
const [ topic, ] = await pubsub.createTopic(name);
return topic;
} catch (err) {
if (err.code === ErrorCodes.AlreadyExists) {
return pubsub.topic(name);
}
throw err;
}
};
So my plea
What are the reasons this might happen, I cannot try to think that one way or the other the first variable can be undefined, so just wondering what is wrong