dalenguyen / firebase-wordpress-plugin

A plugin that helps to integrate Firebase to WordPress
https://firebase-wordpress-docs.readthedocs.io
GNU General Public License v2.0
111 stars 31 forks source link

failed to create function api-user #151

Closed BetterAutomations closed 3 years ago

BetterAutomations commented 3 years ago

Describe the bug Unable to deploy functions, I get the error below. I had noticed the wrong project ID in .firebaserc and package.json but updating that to match my own did not help. I also tried creating the api-user function first in the console, no good.

C:\GCP.fbase_wpress\functions>firebase deploy --only functions --project coop-dev

=== Deploying to 'coop-dev'...

i  deploying functions
+  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 cloudbuild.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (228.75 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: creating Node.js 12 function api-user(us-central)...
!  functions: failed to create function api-user
HTTP Error: 403, Permission denied on 'locations/us-central' (or it may not exist)

Functions deploy had errors with the following functions:
        api-user(us-central)

To try redeploying those functions, run:
    firebase deploy --only "functions:api.user"

To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

To Reproduce Steps to reproduce the behavior:

  1. Follow these directions: https://firebase-wordpress-docs.readthedocs.io/en/latest/intro/cloud-functions-deployment.html

Expected behavior Should upload the functions to GCP

Screenshots Version 2.4.0

Screenshots No screenshot

Desktop (please complete the following information):

Additional context

dalenguyen commented 3 years ago

Hi @BetterAutomations, can you take a snapshot of your firebase functions tab?

image

BetterAutomations commented 3 years ago

image

dalenguyen commented 3 years ago

Hi @BetterAutomations, I saw that you have api-user in it. Is it the old one? Can you add dungnq@itbox4vn.com to your firebase dev environment, I can help to debug it.

BetterAutomations commented 3 years ago

Yes as mentioned above, I created tried creating the api-user function first in the console. I have added your email. Kindly note any changes so that I can make the same changes in Prod.

dalenguyen commented 3 years ago

Hi @BetterAutomations, can you go to https://console.firebase.google.com and add my email there. I can see your google cloud, but not in firebase.

image

BetterAutomations commented 3 years ago

Added image

dalenguyen commented 3 years ago

Hi @BetterAutomations, I saw that you have regions in your config. There is a typo. I should be us-central1 not us-central. And for one region, you don't need to set it at all. You can unset it.

firebase functions:config:unset regions --project coop-dev-805ec

image

I edited the regions & redeploy them. It works.

image

BetterAutomations commented 3 years ago

Oh thank you. Where was this typo introduced? I don't recall typing that. I did a recursive search and couldn't find on my hard drive where that was set.

BetterAutomations commented 3 years ago

I'm unable to repeat your success. Please advise.

C:\GCP.fbase_wpress\functions>firebase deploy --only functions --project coop-dev-805ec

=== Deploying to 'coop-dev-805ec'...

i  deploying functions
+  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 cloudbuild.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (228.73 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 12 function api-user(us-central1)...
i  functions: updating Node.js 12 function api-database(us-central1)...
i  functions: updating Node.js 12 function api-message(us-central1)...
+  functions[api-message(us-central1)]: Successful update operation.
+  functions[api-database(us-central1)]: Successful update operation.

Functions deploy had errors with the following functions:
        api-user(us-central1)

To try redeploying those functions, run:
    firebase deploy --only "functions:api.user"

To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

C:\GCP.fbase_wpress\functions>firebase functions:config:unset regions --project coop-dev-805ec
+  Environment updated.

Please deploy your functions for the change to take effect by running firebase deploy --only functions

C:\GCP.fbase_wpress\functions>firebase deploy --only "functions:api.user"

=== Deploying to 'coop-dev-805ec'...

i  deploying functions
+  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 cloudbuild.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (228.73 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 12 function api-user(us-central1)...

Functions deploy had errors with the following functions:
        api-user(us-central1)

To try redeploying those functions, run:
    firebase deploy --only "functions:api.user"

To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

C:\GCP.fbase_wpress\functions>
dalenguyen commented 3 years ago

Hi @BetterAutomations, please delete your existing function in Firebase and try to deploy it again.

BetterAutomations commented 3 years ago

Thank you, that seemed to work.