You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Firebase相关版本后部分触发器报参数错误求助

Fixing the "Cloud function needs to be called with an event parameter" Error After Firebase Upgrade

Let's get straight to the root of your problem: your dependency versions are out of sync, and that's causing conflicts between the new firebase-functions v2.x and the outdated firebase-admin v5.13.0 you're still using. Node 8's runtime expects a more modern API that your old admin package can't provide, which is why you're seeing that event parameter mismatch error.

What's Specifically Wrong:

  • firebase-functions v2.x is built for Node 8+, but it requires a compatible firebase-admin version (at least v6.x, preferably newer). Your v5.13.0 admin package uses outdated APIs that clash with the new functions runtime, leading to the event parameter error.
  • Your TypeScript version (3.1.3) is also fairly old—while it might compile your code, it could be missing type definitions that the newer Firebase packages rely on, adding to runtime confusion.

Step-by-Step Fixes:

1. Update Your Dependencies to Compatible Versions

Replace the dependencies in your package.json with this set of stable, Node 8-compatible versions:

"dependencies": {
  "@firebase/database": "^0.10.0",
  "cors": "^2.8.5",
  "elasticsearch": "^16.7.3",
  "firebase-admin": "^8.13.0",
  "firebase-functions": "^3.14.1",
  "moment": "^2.29.4",
  "nodemailer": "^6.9.1",
  "request": "^2.88.2",
  "request-promise": "^4.2.6",
  "stripe": "^8.222.0",
  "twilio": "^3.86.1",
  "twitter": "^1.7.1"
},
"devDependencies": {
  "tslint": "^6.1.3",
  "typescript": "^3.9.10"
}

These are the latest stable releases fully compatible with Node 8—you can cross-verify each package's engines field if you want to double-check compatibility.

2. Audit Your wasTriggered Function

Your trigger calls wasTriggered(context.eventId, 'userFollowingChanged')—make sure this custom function isn't using deprecated Firebase APIs. For example:

  • Avoid accessing private properties on the context object
  • If it's meant to prevent duplicate triggers, confirm it correctly handles the eventId in the new runtime

3. Recompile and Deploy

Run these commands to refresh dependencies, build your code, and push it to Firebase:

npm install
npm run build
firebase deploy --only functions

Quick Validation Tips:

  • Test locally first with firebase functions:shell—simulate a Firestore write event to see if the error disappears
  • Check your function logs with firebase functions:log to catch any hidden compatibility issues

内容的提问来源于stack exchange,提问作者Aswin T K

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:35:50