使用“部署错误:未定义”删除失败的Firebase云功能

时间:2017-07-31 16:01:11

标签: firebase firebase-realtime-database google-cloud-functions

如何删除使用Deploy Error: undefined部署的 Firebase云功能

<小时/>

重现我的问题的步骤:

1)创建一个新的 Firebase 项目

2)$ firebase init和设置功能

3)将以下代码粘贴到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)该功能将无法按预期部署。

<小时/>

我尝试删除云功能

  • index.js删除该功能并进行部署不会删除该功能,而是获得functions[thisFnWillFailToDeploy]: Deploy Error: undefined
  • 删除 Google Cloud Console 中的云功能不会删除该功能。 (我得知这个函数将被删除,但事实并非如此。在日志中出现"status":{"code":13}错误
  • 创建名为thisFnWillFailToDeploy的空云功能也会产生Deploy Error: undefined

1 个答案:

答案 0 :(得分:2)

项目中的该功能处于不良状态。显然,部署具有格式错误的ref的函数会导致该函数出现问题而无法自行解决。该功能将从一开始就无法部署(甚至没有机会删除它)。之后,您无法再更新或删除该功能。如果您需要,您必须联系支持部门以恢复该功能。您仍然可以更新或删除该项目中的其他功能。

我猜这是因为你的函数调用中有一个拼写错误,它产生了ref的名字。你在aFunction的召唤中错过了一些parens。我想你的意思是这样的:

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

如果您在新项目中部署它,它应该可以工作。