firebase - Google Cloud Functions Cron 作业不起作用

标签 firebase google-cloud-functions google-cloud-pubsub firebase-tools

我正在尝试设置一个 scheduled function在 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's local emulator 上的文档:

The Firebase CLI includes a Cloud Functions emulator which can emulate the following function types:

  • HTTPS functions
  • Callable functions
  • Cloud Firestore functions

所以本地 Firebase 模拟器目前不支持 pubsub,错误消息似乎证实了这一点。因此,目前您无法在本地运行 pubsub 触发的 Cloud Functions。
adding PubSub support to the emulator 的功能请求被归档。您可能想在那里阅读(并可能发表评论),因为所采取的方向可能符合也可能不符合您的需求。
本地shell 支持 invoking pubsub functions .这当然是完全不同的,但作为目前的解决方法可能很有用。

关于firebase - Google Cloud Functions Cron 作业不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59346125/

相关文章:

android - 当没有互联网连接时使用 FCM 发送推送通知

javascript - Vue.js 和 Firebase 'User' 信息

google-cloud-functions - 如何在 Google Dialogflow Phone Gateway 中访问来电者电话号码?

google-cloud-pubsub - 为什么 Google PubSub 总是创建 60 个永久线程?

java - 如何将上传到云存储的图片调整为指定大小?

firebase - 如何从firebase函数访问firestore

javascript - 从 Firestore 读取不会返回任何内容

java - Google Cloud Pub/Sub,Java 客户端不发布消息

google-cloud-platform - 为 Pubsub 到 Bigquery 流构建此 GCP 数据流示例时出错

ios - 来自 Firebase 数据库的 TableViewCell 数据