Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually trigger scheduled or trigger function

Is there any way to manually trigger a scheduled function and/or a Firestore trigger function? I have two scenarios I need to solve:

  1. A cloud function that is listening to a Firestore document (onCreate) didn't fire - it failed on 3 of about 1,000 invocations, so I need to manually trigger it for these 3 documents. Is this possible (to manually trigger this function)?
  2. I have a scheduled function that runs hourly, but threw an error b/c of a map in the Firestore document when the code expected an array. Any way I can manually run the scheduled function once rather than waiting an hour before it runs again?
like image 200
I'm Joe Too Avatar asked Jun 06 '26 11:06

I'm Joe Too


2 Answers

  • Go to the Firebase console
  • Select the desired project
  • Select the Functions menu item from the left sidebar
  • Open the ... menu at the right side of the cron job
  • Select the View in Cloud Scheduler menu item
  • Open the ... menu at the right side of the cron job
  • Select the Force run menu item
like image 129
ultraGentle Avatar answered Jun 09 '26 00:06

ultraGentle


You can run a firestore scheduled function via the FirebaseTools and running it locally. Starting the shell command eg npm run build && firebase functions:shell will allow you to invoke a Scheduled Function eg:

export const parseGarminHealthAPIActivityQueue = functions.region('europe-west2').runWith({
  timeoutSeconds: TIMEOUT_IN_SECONDS,
  memory: MEMORY
}).pubsub.schedule('every 10 minutes').onRun(async (context) => {
  await parseQueueItems(ServiceNames.GarminHealthAPI);
});
like image 31
Jimmy Kane Avatar answered Jun 08 '26 23:06

Jimmy Kane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!