简体   繁体   中英

firebase cloud functions v2 - custom event trigger not deployed

I am attempting to follow this guide https://firebase.google.com/docs/functions/beta/custom-events to add v2 cloud function to handle a custom event provided by firebase stripe extension. The deploy commands seems to run without errors, but my new function does not appear in cloud console.

My firebase cli version is 10.2.1

I import functionsV2 using const functionsV2 = require("firebase-functions/v2");

My function signature is like this

exports.stripetrialupdated = functionsV2
    .eventarc
    .onCustomEventPublished(
        {
          eventType: "com.stripe.v1.customer.subscription.updated",
          channel:
          "projects/success-academy-5eed2/locations/us-west1/channels/firebase",
          region: "us-west1",
        },
        (event) => {...});

However, when I try to deploy using firebase deploy --only functions , all functions except this one are deployed. My other functions are HTTP triggers and deploy fine, and all functions are in the same index.js file. There is no error message, just this function does not appear in the deploy command output. Also, running firebase deploy --only functions:stripetrialupdated results in

i  deploying functions
Running command: npm --prefix functions run lint

> functions@ lint /Users/gmiao/workspace/success-academy-5eed2/functions
> eslint .

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (82.12 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: cleaning up build files...

✔  Deploy complete!

I still do not use version 2 because it has recently come out, but could it be that since you are recording custom events, they do not appear in the console but are still present? Have you tried to enter console.log ("called") somewhere? It might be a silly question but I'm asking you because you didn't write it in the question. Also, what does the cloud function console indicate after loading the function?

Thanks for the suggestions, but I ended up just handling the stripe http webhook events directly instead of using eventarc trigger.

https://medium.com/@GaryHarrower/working-with-stripe-webhooks-firebase-cloud-functions-5366c206c6c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM