skip to Main Content

EDIT: As I dig deeper into the logs from the debugger, I am noticing that even though I am making changes to the scheudle/timezone of my function, it does not update in the logs, indicating that it is trying to upload a cached version maybe. I don’t know how to clear cache but that’s my next step.

I have been using RNFB for over a year now. I have a handful of cloud functions I created at one point. I have a CloudFunctions subdirectory in my RN project where I cd into it, I write functions, and I deploy them to the cloud. This worked well for a while and I was scheduling jobs and deploying constantly.

I only have 3 functions total, but today I noticed when trying to deploy a fourth using firebase deploy --only functions:functionName. When doing this, it passed all steps except the last one which said there was an issue with the timezone or schedule which is weird because I copy and pasted it from another function that works. I then tried creating completely new functions and it says they deploy in the CLI, but they never show up in my Firebase Web Portal/Console. Any idea why this would be? I am logged in to my FB account and I am linked to the proper project. I checked that.

All my functions are on us-central1.

CODE

exports.functionName = functions.pubsub
  .schedule('every 1 minutes')
  .timeZone('America/Chicago')
  .onRun(async () => {
    console.log('Running functionName() ');
    //
    //
    //
    console.log('---Exiting functionName()...');
  });

I RUN:
firebase deploy --only functions:functionName

ERROR – occurs right at the step of: i functions: updating Node.js 16 function functionName(us-central1)...

Failed to create scheduler job projects/projectName/locations/us-central1/jobs/firebase-schedule-functionName-us-central1: HTTP Error: 400, Schedule or time zone is invalid.
Functions deploy had errors with the following functions:
        functionName(us-central1)

I will also add that I see this function in my firebase console but it refuses to add any frequency. Next to the clock there should be "every 1 minute". If I delete this function from the Firebase Console and redeploy, I get the same redeploy error, but it still puts the function in my console on the web just like you see it below.

enter image description here

Followup – I tried changing the schedules of some of my working cloud functions and they won’t update despite the fact that the CLI says it deployed. Also, here is some more context from my debugging log:

  "op": "upsert schedule",
  "original": {
    "name": "FirebaseError",
    "children": [],
    "exit": 1,
    "message": "Failed to create scheduler job projects/projectName/locations/us-central1/jobs/firebase-schedule-functionName-us-central1: HTTP Error: 400, Schedule or time zone is invalid.",
    "status": 500
  }
}
[2023-07-12T04:19:19.914Z] Error: Failed to upsert schedule function functionName in region us-central1
...

followed by more stack trace about fabricator.

2

Answers


  1. Chosen as BEST ANSWER

    After TONS of toiling over this I figured out what the issue was. I am developing in TS and NOT in JS. When I was deploying previously, every time I did it the TS got recompiled into JS and the JS version got uploaded to firebase. For some reason it stopped auto-compiling during a run when I had made a mistake in the schedule for my cloud function.

    So, every subsequent attempt to deploy failed because it was working off of the most recently compiled js file which was WAY out of date.

    Anyway, to anyone who read this and tried to help, thank you. To anyone with a similar issue in the future, good luck - hopefully this is helpful.


  2. It seems like there’s a problem with the time zone being invalid. Even though your time zone could be correct, I tried recreating it with the same setup and time zone, and it worked fine. However, when I checked my function on the firebase console, it still showed the same time zone. I tried deploying another function without specifying a time zone, but it still showed the same time zone.

    According to this document it says the time zone must be from tz database.

    So I will recommend you to use just a normal time zone. Below is modified code :

    import * as functions from "firebase-functions";
    
    export const scheduled = functions.pubsub
      .schedule("every 1 minutes") // This will work same as America/Chicago
      .onRun(async () => {
        console.log("Running functionName() ");
        //
        console.log("---Exiting functionName()...");
      });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search