20
votes

Is there a way to disable a Cloud Function for Firebase through the Firebase dashboard?

I deployed a Cloud Function with a bug which caused an infinite loop of the function being triggered, updating the data, then the function triggering again. I discovered the error quickly, but I had to fix the code and redeploy the entire project to get the function to stop triggering.

Even though I deployed the new function, the deployment took some time and the function was triggered hundreds of times (which actually caused others to be triggered hundreds of times).

I'd like to be able to disable a function immediately when this happens, but I don't see any options in the dashboard or through the Firebase CLI.

4

4 Answers

7
votes

Dont want to delete the function as I want to keep the usage history, logs, health ect? This work around,long winded, but does the trick:

Disable function:

  • comment out the code in then function in your index.js
  • deploy just the firebase function:

firebase deploy --only functions:functionName

Enable function:

  • uncomment code
  • redeploy just the function with above line

Unfortunately Firebase has only a delete option and no disable option :(

21
votes

If you view Cloud Functions in the Cloud Console, you can delete them individually from there: https://console.cloud.google.com/functions

1
votes

A thing that I'm doing which isn't particularly neat but does the job. is just add a node in the database. for me I have a weekly script I run where I don't want my cloud functions to run when that's running. so at the top of my function I read that node and if the script is running, I just return early. not ideal but saves me having to comment out and redeploy every time

1
votes

For me the fastest way is to edit function code directly in Google Cloud Console editor. In case of the HTTP function adding something like this at the beginning of a handler

res.status(500).send('The function is disabled');
    return;