Search code examples
javascriptfirebasegoogle-cloud-functionsgoogle-cloud-pubsub

How to invoke firebase Schedule functions locally using pubsub emulator


I am working on cloud functions especially schedule functions. I need to trigger a function periodically each 5 minutes, but in only test step. I need to run it on pubsub emulator without deploying it.

How to do it?

I tried to use firebase shell, but it triggered only once

 exports.scheduledFunctionPlainEnglish =functions.pubsub.schedule('every 2 minutes')
 .onRun((context) => {
    functions.logger.log("this runs every 2 minutes")
    return null;
}) 

Solution

  • This is currently not supported for scheduled functions. The documentation states:

    Using the shell, you mock data and perform function calls to simulate interaction with products that the Emulator Suite does not currently support: Storage, PubSub, Analytics, Remote Config, Storage, Auth, and Crashlytics.

    Scheduled functions are an unsupported extension of pubsub triggers.

    Feel free to file a feature request with Firebase support.