firebase - 如何在 Firebase Functions shell 中运行 Pub-Sub 函数
问题描述
我无法在本地 Cloud Functions Shell 中运行我的 pub-sub 触发器。我通过以下方式创建了 Cloud Functions:
export const sendNotifications = functions.pubsub.schedule('0 10 * * *').timeZone('Asia/Kolkata').onRun(async (context) => {
console.log('running sendNotificationForActivities');
await sendMessages();
return 0;
}
如此处所述,我尝试firebase functions:shell
从我的系统运行,然后:
> sendNotifications({data: new Buffer('{"hello":"world"}'), attributes: {foo: 'bar'}})
或者
> sendNotifications({})
和其他变体。以下是我收到的错误堆栈跟踪:
firebase > sendNotificationForActivities({})
'Successfully invoked function.'
firebase > ⚠ TypeError: Cannot read property 'params' of undefined
at cloudFunction (/Users/mayurdhurpate/code/pruoo_app/backend_admin/functions/node_modules/firebase-functions/lib/cloud-functions.js:109:38)
at Run (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:458:20)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:442:19
at Generator.next (<anonymous>)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
at Run (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:435:12)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:457:15
at Generator.next (<anonymous>)
⚠ Your function was killed because it raised an unhandled error.
我想我可能缺少必填params
字段,但找不到输入参数的正确方法。我firebase-tools@7.1.1
在 MacOS 上使用。
解决方案
推荐阅读
- fortran - 如何在 Fortran 的代码中直接用“许多数字”设置向量的值?
- c# - 单击带有 IF 的 web 元素时如何处理 ElementClickInterceptedException
- android - 我如何在android中使用导航栏和导航图
- bash - 木偶:“错误:无法从远程服务器检索目录”将代码添加到配置文件后
- javascript - 如何解决jquery自动完成问题
- html - 如何从 tvdb 中抓取剧集编号
- react-native - 如何将边框半径应用于 Expo LinearGradient 组件的某些角
- html - .active 类在 Bootstrap 3 进度条和加载动画中不起作用
- android - 以下布局的表格格式未在 android 中显示
- javascript - 无法从 index.js 注入 html