Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Cloud Functions for Firebase through Firebase dashboard (or cli)

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.

like image 874
doowb Avatar asked May 22 '17 19:05

doowb


4 Answers

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 :(

like image 35
Haider Malik Avatar answered Nov 03 '22 04:11

Haider Malik


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

like image 102
Ian Barber Avatar answered Nov 03 '22 05:11

Ian Barber


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

like image 2
Red Baron Avatar answered Nov 03 '22 04:11

Red Baron


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;
like image 1
Pavel Shastov Avatar answered Nov 03 '22 03:11

Pavel Shastov