4

I use Firebase Cloud Functions in my project, and I have a plenty of them so when I run the regular firebase deploy I exceed the quota, so one option is to deploy only the function that was modified by using firebase deploy --only functions:function1 as mentioned in this web page. This method works only with functions that start with: exports.funcName but when I try to use it with a function like this:

function doesNotStartWithExports() {
    // Does something.
}

It doesn't work. I use firebase deploy --only functions:doesNotStartWithExports but I get this output:

⚠  functions: the following filters were specified but do not match any functions in the project: doesNotStartWithExports

The Question: How to deploy Firebase functions that does not start with exports?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Ameer Taweel
  • 949
  • 1
  • 11
  • 37

4 Answers4

6

I faced a very similar error while trying to delete some deprecated functions:

firebase functions:delete mymodule-helloWorld --region us-central1

Output:

Error: The specified filters do not match any existing functions in project my-firebase-project.

Turns out that if I replace the '-' in namespaced/grouped (module) functions with '.', the error goes away. Weird.

firebase functions:delete mymodule.helloWorld --region us-central1

Output:

? You are about to delete the following Cloud Functions:
    mymodule-helloWorld(us-central1)
  Are you sure? Yes
i  functions: deleting function mymodule-helloWorld(us-central1)...
✔  functions[mymodule-helloWorld(us-central1)]: Successful delete operation.

The solution is adapted from this github thread

kip2
  • 6,473
  • 4
  • 55
  • 72
  • awesome, to delete multiple functions, use `firebase functions:delete mod-function1 mod-function2 mod-function3` i.e. use a space between function names – CybeX May 15 '22 at 06:29
4

I actually found the solution, and it's by deploying one of the function that starts with exports and uses the function that doesn't start with exports, for example:

function doesNotStartWithExports() {
    // I want to deploy only this function but I can't
}

exports.anotherFunction = functions.https.onRequest((request, response) => {
    // This functions uses the one that I want to deploy.
    doesNotStartWithExports()
})

To update doesNotStartWithExports I use this command: firebase deploy --only functions:anotherFunction.

Ameer Taweel
  • 949
  • 1
  • 11
  • 37
2

I also found that if you have a regular function exported somewhere with the same name as the Firestore function you will get this error:

export myFunction() {
  // do somethig here
} 

exports.myFunction = functions.https.onCall((data, context) => {
  // function
})

renaming either of them to a unique name will solve the issue.

0

This works: enter image description here

But this does not work (extra lines preceding function) enter image description here

Ramesh Vishnoi
  • 1,299
  • 1
  • 12
  • 19