firebasefirebase-realtime-databasegoogle-cloud-functions

Delete a Firebase Cloud Function which failed with `Deploy Error: undefined`


How can I delete a Firebase Cloud Function which deployed with Deploy Error: undefined?


Steps to reproduce my problem:

1) Create a new Firebase project

2) $ firebase init and setup functions

3) Paste the following code into functions/index.js

"use strict";
const functions = require('firebase-functions');

function aFunction() {
    return 'reports/posts';
}

function getCorruptTrigger() {
    return '/reports/posts/' + aFunction +'/createdAt'
}

exports.thisFnWillFailToDeploy = functions
    .database
    .ref(getCorruptTrigger())
    .onWrite(event => {});

4) firebase deploy --only functions

5) The function will fail to deploy as expected.


What I tried to delete the Cloud Function:


Solution

  • That function in your project is in a bad state. Apparently, deploying a function with a malformed ref causes problems with that function that can't be reversed on your own. That function will failed to deploy from the outset (not even having a chance to delete it yet). After that, you can no longer update or delete the function. You'll have to contact support to recover the function, if that's what you need. You should still be able to update or delete other functions in that project.

    I'm guessing it's because you have a typo in your function call that generated the name of the ref. You're missing parens on the call to aFunction. I imagine you meant for it to look like this:

    function getCorruptTrigger() {
        return '/reports/posts/' + aFunction() +'/createdAt'
    }
    

    If you deploy that in a new project instead, it should work.