how to use firebase cloud function pubsub.schedule?

Today, there is new feature of Cloud Functions for Firebase which is running functions on a schedule. So I tried to test the sample code.

index.js file
exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
  console.log(‘This will be run every 5 minutes!’);
});

But when I tried to deploy this, I got the following error message:


Error: Error occurred while parsing your function triggers.

TypeError: functions.pubsub.schedule is not a function

My firebase tools version is 6.7 (updated today)

What is the solution?

I checked the example git code in here (https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js)

But it also cause the same error:

functions.pubsub.schedule is not a function

Can anyone help me with this problem?

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
   console.log('This will be run every 5 minutes!');
});

The announcement blog post points out that the version of the firebase-functions module also needs to be minimum 2.3.0. Run npm install firebase-functions@latest in your functions folder to update it, then build and deploy again.

how to use firebase cloud function pubsub.schedule?, The announcement blog post points out that the version of the firebase-functions module also needs to be minimum 2.3.0. Run npm install� Today, there is new feature of Cloud Functions for Firebase which is running functions on a schedule. So I tried to test the sample code. index.js file exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => { console.log(‘This will be run every 5 minutes!’);

I had the same issue.

I had to update my firebase-tools to version ^6.7.2. I have also updated firebase-functions but that alone did not do the job. So I would update all firebase dependencies (firebase-tools/admin/functions).

Scheduling Cloud Functions for Firebase (cron), Firebase now supports a new type of Pub/Sub function, built on top of Cloud To get started with scheduled functions using Firebase tools,� For messages with JSON in the Pub/Sub message body, the Firebase SDK for Cloud Functions has a helper property to decode the message. For example, here is a message published with a simple JSON payload:

Here's the documentation https://firebase.google.com/docs/functions/schedule-functions

export const scheduledFunction = functions.pubsub.schedule('every 5 minutes')
.timeZone('Asia/Jakarta')
.onRun((context) => {
    console.log('This will be run every 5 minutes!');
});

And you can set the timeZone as additional

Using Pub/Sub to trigger a Cloud Function, A basic scheduled Cloud Function can be defined on the pubsub namespace. index.ts. export const dailyJob� To get started with scheduled functions using Firebase tools, navigate to the documentation, and check out this sample available in GitHub. Your project must be on the Blaze payment plan, as Cloud Scheduler and Pub/Sub require billing information.

Dynamic Scheduled Background Jobs in Firebase, TypeError: functions.pubsub.schedule is not a function My firebase tools version is 6.7 (updated today) What is the solution? I checked the example git code in� It’s an effective way to schedule a task on a particular frequency, but there hasn’t been a way to do this from within the Firebase SDK until very recently. In this article, we’ll be investigating how to do this with a new Firebase Cloud Functions project using Node.js. As always, we’ll be starting out with a brand new project:

how to use firebase cloud function pubsub.schedule?, the use case where I needed to schedule a Firebase Cloud Function on a Let's move over to Cloud Pub/Sub in our Google Cloud Platform� This tutorial shows you how to use Cloud Scheduler and Pub/Sub to trigger a Cloud Function. Being able to schedule the execution of a Cloud Function is a common use case for Cloud Scheduler. You will: Create a simple Cloud Function that subscribes to a Pub/Sub topic. Create a Pub/Sub topic to trigger that function.

Scheduling Firebase Cloud Functions with Cloud Scheduler, Triggering Firebase Cloud Functions on a regular basis with up all the pieces yourself and using gcloud or the Google (not Firebase) Cloud The PubSub trigger type now supports schedule in addition to topic triggers. Developer Programs Engineer Cloud Functions are a great solution for running backend code for your Firebase app. You can write a function which is triggered by many different actions like user sign-ups, writes to the Realtime Database, changes to a Cloud Storage bucket, or conversion events in Firebase Analytics.

Comments
  • This one fixed the issue for me. If it fixed your issue too @SssSteve, this should be the accepted answer.
  • This worked for me. Installed in the functions root folder.
  • I got this error functions[scheduledFunction]: function ignored because the pubsub.googleapis.com emulator does not exist or is not running.
  • I am using "firebase-functions": "^3.3.0" , still i am having this issue
  • Not relating at all