Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Firebase函数shell中运行Pub Sub函数_Firebase_Google Cloud Platform_Google Cloud Functions_Google Cloud Pubsub_Firebase Cli - Fatal编程技术网

如何在Firebase函数shell中运行Pub Sub函数

如何在Firebase函数shell中运行Pub Sub函数,firebase,google-cloud-platform,google-cloud-functions,google-cloud-pubsub,firebase-cli,Firebase,Google Cloud Platform,Google Cloud Functions,Google Cloud Pubsub,Firebase Cli,我无法在本地云函数Shell中运行pub-sub触发器。我以以下方式创建了云函数: export const sendNotifications = functions.pubsub.schedule('0 10 * * *').timeZone('Asia/Kolkata').onRun(async (context) => { console.log('running sendNotificationForActivities'); await sendMessages

我无法在本地云函数Shell中运行pub-sub触发器。我以以下方式创建了云函数:

export const sendNotifications = functions.pubsub.schedule('0 10 * * *').timeZone('Asia/Kolkata').onRun(async (context) => {
    console.log('running sendNotificationForActivities');
    await sendMessages();
    return 0;
}
如前所述,我尝试从我的系统中运行
firebase函数:shell
,然后:

> sendNotifications({data: new Buffer('{"hello":"world"}'), attributes: {foo: 'bar'}})

和其他变体。以下是我收到的错误堆栈跟踪:

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.
firebase>sendNotificationForActivities({})
“已成功调用函数。”
firebase>⚠  TypeError:无法读取未定义的属性“params”
在cloudFunction(/Users/mayurdhurpate/code/pruoo_app/backend_admin/functions/node_modules/firebase functions/lib/cloud functions.js:109:38)
运行时(/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:458:20)
位于/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:442:19
在Generator.next()处
位于/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:7:71
在新的承诺()
在u waiter(/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
运行时(/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:435:12)
位于/Users/mayurdhurpate/.npm global/lib/node_modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:457:15
在Generator.next()处
⚠  函数被终止,因为它引发了未处理的错误。
我想我可能缺少必需的
params
字段,但我找不到输入参数的正确方法。我正在使用
firebase-tools@7.1.1
在MacOS上。

我也有同样的错误。 错误位于cloudfunctions.js:117:28中

即使上下文不存在,他也试图访问上下文的键

我已更新到最新版本,但错误仍然存在

作为解决方法,我在cloud-functions.js的第89行添加了这段代码:context=context |{}

这解决了错误,我可以使用firebase外壳

我希望这个讨厌的黑客能有所帮助。 直到谷歌修复他们的代码或更新文档


Dominik

你在GitHub上提交了问题吗?嗨!不,我没有。如果您在Firebase CLI中发现错误,请提交报告。这会有帮助的。
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.