Every wonder how to trigger Firebase scheduled (pubsub) functions directly from localhost during development? It’s actually quite easy, but for some reason not very well documented.

Start by installing Firebase CLI:

npm install -g firebase-tools

Setup local Firebase emulators:

firebase init emulators

Make sure that your firebase.json has a pubsub port defined.

"emulators": {
  ...
  "pubsub": {
    "port": "8085"
  }

Start your local emulators:

firebase emulators:start

Shell into the running Firebase emulator instance

firebase functions:shell

You can now trigger any functions.pubsub.schedule directly from this prompt. E.g:

scheduleNotifier();

You’re now able to significantly improve your firebase function development, since you can trigger the scheduled functions interactively.

firebase > scheduleNotifier();
'Successfully invoked function.'
firebase > >  No matching documents.
>  Notifier done: 0
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *