GoogleCloudPlatform / functions-framework-nodejs

FaaS (Function as a service) framework for writing portable Node.js functions
Apache License 2.0
1.29k stars 158 forks source link

Firebase functions pubsub trigger does not receive proper information #578

Closed szaleq closed 10 months ago

szaleq commented 10 months ago

I have a problem with firebase pubsub trigger - the function causes error in firebase-functions code because some param is undefined.

I published an issue infirebase-functions repo here but don't know it's a problem with firebase-functions or somewhere else...? It seems that the argument passed to the pubsub trigger is undefined instead of being an object with published message data.

I have a simple function using v2 pubsub trigger, which should capture published message and save it into firestore. The function looks like this:

const onProfileCreated = onMessagePublished(
    TOPIC_NAME,
    (event) => handleMessagePublished(event.data.message.json) // this function should just store message data in firestore
);

While working perfectly well in local development using firebase emulators, this function's code doesn't get executed when deployed because of an error in firebase-functions code:

TypeError: Cannot read properties of undefined (reading 'messageId')
    at new Message (/workspace/node_modules/firebase-functions/lib/v2/providers/pubsub.js:65:31)
    at func (/workspace/node_modules/firebase-functions/lib/v2/providers/pubsub.js:127:40)
HKWinterhalter commented 10 months ago

Closing this as it seems like the firebase repo owners have asked for more debug info but the issue has been closed due to no response.