我正在尝试建立一个预定功能 https://firebase.google.com/docs/functions/schedule-functions在 Firebase 云功能中。作为一个简单的测试,我尝试重新创建文档页面上显示的示例:
const functions = require('firebase-functions')
exports.scheduledFunction = functions.pubsub
.schedule('every 5 minutes')
.onRun(context => {
console.log('This will be run every 5 minutes!')
return null
})
然而,当我跑步时firebase serve --only functions
,我收到以下错误:
function ignored because the pubsub emulator does not exist or is not running.
知道为什么我会收到此消息以及如何修复它吗?
从文档上Firebase 本地模拟器 https://firebase.google.com/docs/functions/local-emulator:
Firebase CLI 包含一个 Cloud Functions 模拟器,可以模拟以下函数类型:
- HTTPS功能
- 可调用函数
- Cloud Firestore 功能
因此,本地 Firebase 模拟器当前不支持 pubsub,错误消息似乎证实了这一点。因此,目前您无法在本地运行 pubsub 触发的 Cloud Functions。
功能请求向模拟器添加 PubSub 支持 https://github.com/firebase/firebase-tools/issues/1748被提起。您可能想在那里阅读(并可能发表评论),因为所采取的方向可能符合也可能不符合您的需求。
本地外壳does支持调用 pubsub 函数 https://firebase.google.com/docs/functions/local-shell#invoke_pubsub_functions。这当然是完全不同的,但目前可能作为一种解决方法很有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)