【问题标题】:Error: Cloud function needs to be called with an event parameter. Firebase console error,错误:需要使用事件参数调用云函数。 Firebase 控制台错误,
【发布时间】:2019-09-18 01:46:06
【问题描述】:

我已将 firebase 节点版本从 6 升级到 8,还升级了 firebase-functions、typescript 版本以及 firebase-admin。 但我在少数触发器上遇到此错误。

错误:需要使用事件参数调用云函数。如果>您正在编写单元测试,请使用Node模块firebase-?>functions-fake。 在对象。 (/srv/node_modules/firebase->functions/lib/cloud-functions.js:84:19)

exports.userFollowingChanged = functions.firestore
  .document("Db1/{domainName}/Users/{byUser}/toIds/{toId}")
  .onWrite((change, context) => {
    return wasTriggered(context.eventId, 'userFollowingChanged').then(() => {
      return userFollowingChanged(change, context)
    });
  });

我的package.json如下

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc --skipLibCheck",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@firebase/database": "0.1.9",
    "cors": "^2.8.4",
    "elasticsearch": "^15.1.1",
    "firebase-admin": "~5.13.0",
    "firebase-functions": "^2.0.0",
    "moment": "^2.20.1",
    "nodemailer": "^4.6.0",
    "request": "^2.83.0",
    "request-promise": "^4.2.2",
    "stripe": "^5.5.0",
    "twilio": "^3.12.0",
    "twitter": "^1.7.1"
  },
  "devDependencies": {
    "tslint": "^5.8.0",
    "typescript": "^3.1.3"
  },
  "private": true,
  "engines": {
    "node": "8"
  }
}

谁能解释一下这个触发器有什么问题? 它在节点运行良好:6 关于版本问题,我在堆栈溢出中看到了相同的问题。

【问题讨论】:

  • 您在哪里看到该错误?你在做什么来触发它?请告诉我们你在做什么。
  • 您找到解决方案了吗?从节点 6 升级到 8 后,我使用 onWrite 或 onCreate 的所有函数都遇到了同样的问题?
  • 对我来说将 firebase-functions 升级到 3.3.0 后它正在工作

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


【解决方案1】:

升级 firebase 功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-07
    • 2018-08-28
    • 2021-08-29
    • 1970-01-01
    • 2020-02-03
    • 2017-02-22
    • 1970-01-01
    • 2016-12-05
    相关资源
    最近更新 更多