2
votes

When I try to deploy my newly created Firebase PubSub function, I get the error Error: Failed to create scheduler job projects/workouts-uat/locations/europe-west1/jobs/firebase-schedule-dailyTasks-eur3: HTTP Error: 400, Schedule or time zone is invalid.

My function is declared as follows:

exports.dailyTasks = functions
  .region('europe-west2')
  .pubsub
  .schedule('every 24 hours 00:00')
  .timeZone('Africa/Johannesburg')
  .onRun(...);

From my research I found that that the region used should be the same as the region found in your project settings, which in my case is eur3 (europe-west). All my existing onCall functions use europe-west2 which is why I tried to go with that first, but after finding my project settings region I updated to .region('eur3') and .region('europe-west'), but the error persists. So how do I successfully deploy this function?

Another hint I came across while googling the error was that a "Google App Engine (GAE) app" has to be created for pubsub functions to work, but I'm assuming that happens automatically on function deploy, right? Otherwise how does one create that? I have zero experience with GCP.

1

1 Answers

3
votes

I finally figured this out. It had nothing to do with the .timeZone(), as I originally thought - it was an error with the .schedule(). And yes, I just saw that the error message does include the possibility that it could be the "Schedule or time zone", but for some reason I thought it was referring to the function as a whole and not the .schedule() call.

In any case, once I updated my every 24 hours 00:00 to every day 00:00, it all of a sudden deployed just fine. For clarity, this is what my working function signature now looks like:

exports.dailyTasks = functions
.region('europe-west2')
.pubsub
.schedule('every day 00:00')
.timeZone('Africa/Johannesburg')

As it turns out, .region() also had nothing to do with it, and europe-west2 works just fine.

I'd like to thank the author of this article, because he linked an example project that also calls a pubsub function every day at midnight, and without said article, I'd have never found the answer.