【问题标题】:Firebase Functions Deployment Failed [duplicate]Firebase 功能部署失败 [重复]
【发布时间】:2020-11-13 01:15:13
【问题描述】:

我一直在尝试部署名为 onFollowUser 的 firebase 函数,但是它一直无法启动。我目前有 Blaze 计划,这是错误消息:

⚠  functions[onFollowUser(us-central1)]: Deployment error.
Failed to configure trigger providers/cloud.firestore/eventTypes/document.create@firestore.googleapis.com (__gcf__.us-central1.onFollowUser)


Functions deploy had errors with the following functions:
        onFollowUser


To try redeploying those functions, run:
    firebase deploy --only functions:onFollowUser


To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

这是我完整的index.js

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.onFollowUser = 
functions
.firestore
.document('/Followers/{userID}/User Follower/{followerID}')
.onCreate(async (snapshot, context) => {
    console.log(snapshot.data());
});

我发现了错误...我的数据库位于欧洲中部,但是,由于某种原因,它正在部署到美国中部...我该如何更改?它说它正在部署到的我的项目的 ID 是正确的。

这是我的 package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "10"
  },
  "dependencies": {
    "firebase-admin": "^8.10.0",
    "firebase-functions": "^3.6.1"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.2.0"
  },
  "private": true
}

编辑:即使我收到此失败消息,我也可以在控制台上看到该功能:

【问题讨论】:

  • 你能分享你的package.json文件吗?
  • “我的数据库位于欧洲中部,但是,由于某种原因,它正在部署到美国中部...” 在一个位置拥有一个 Firestore 数据库并拥有一个应该没有问题另一个位置的云功能。请参阅以下链接更改区域:firebase.google.com/docs/functions/…
  • 感谢@RenaudTarnec 和 Mike,它现在正在部署
  • 这可能是一个有趣的答案......我部署正确,但随后,我开始遇到同样的问题。在花了 4 个小时试图修复它之后......我发现我的结算帐户已被暂停,因为我最后一次支付 0.01 美元失败了。我刚刚添加了一种新的付款方式,我的部署又开始工作了。

标签: firebase flutter google-cloud-firestore google-cloud-functions


【解决方案1】:

这是一个已知问题,请参阅:Error Deploying Firestore Function with a space in the name of a collection

重命名 a 集合,使其不包含空格,而是使用驼峰式大小写、破折号或下划线。

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
admin.firestore().settings({ timestampsInSnapshots: true });

exports.onFollowUser = 
functions
.firestore
.document('/Followers/{userID}/User-Follower/{followerID}')
.onCreate(async (snapshot, context) => {
    console.log(snapshot.data());
    return;
});

【讨论】:

  • 还是不行...
  • 如果它显示在您的功能列表中,那么它确实在某个阶段进行了部署。尝试触发它并检查日志以查看是否收到更好的错误消息。要尝试的另一件事是将 .document('/Followers/{userID}/User Follower/{followerID}') 更改为 .document('Followers/ {userID}/用户关注者/{followerID}')。
  • 去掉前面的是什么意思?
  • 错误消息没有说部署失败,它说配置触发器提供程序失败。这意味着它不是部署问题,而是代码问题。我注意到您的集合名称中有一个空格,尝试转义它吗?更好的解决方案:不要使用空格,使用驼峰式大小写或破折号或下划线,不需要转义的东西。
  • 子集合名称中的空格确实是问题。
猜你喜欢
  • 2021-12-29
  • 2020-05-23
  • 2021-05-16
  • 1970-01-01
  • 2018-12-06
  • 2021-02-26
  • 2023-04-01
  • 2021-10-05
  • 2020-10-19
相关资源
最近更新 更多