Debugging scheduled jobs in corvid?

Is there a way to debug scheduled jobs in Corvid?

I have created a jobs.config according to the guidelines. I have tested the function I am calling and it works as expected when run manually. However, I cannot seem to get the function to run based on the schedule.

Things I have tried:

  1. I have the “Site Monitoring” open over periods of time when the jobs should run. No logs for scheduled events.
  2. I have created a new collection called “Scheduled Jobs” which I write to at the beginning and the end of the scheduled job function I call. No updates to this table when called via schedule, but works when called manually.

Questions that may help me debug further:

  1. What permission level is a scheduled job given? (Although I do have all collection writes as “SuppressAuth”, but the module itself is restricted to “Admin”)
  2. Does jobs.config allow comments or do I need to delete all of those (i.e., is this pure json)? Sample file had some comments throughout and no errors in the wix editor with comments.

Are there any other ways to see errors from the scheduled jobs in order to help me isolate the problem?

Example entry in my jobs.config file:

// -- 9 AM --     
{  
"functionLocation": "updateRegistrations.updateLaRegistrations",  "description": "9am Get latest registrations", 
"executionConfig": {  
    "time": "13:00" // mandatory, “hh:mm” format
 }     
},
1 Like

Still no luck here. New things I’ve tried.

  • Remove all comments
  • Ensure I have fewer than 20 jobs
  • Make jsw file open to everyone instead of restricted to admin
  • Move code to .js file instead of .jsw
  • Move .js file into folder like described in docs and use /folderName/filename.functionname
  • Make sure I’m waiting 5 minutes before checking as described in docs

@yisrael-wix @stcroppe @aleksander-denga

Been having the exact same issue for the past two weeks. No responses yet.

I’m by no means an expert here, but I think part your problem is the comma. I’ve been fighting with my schedule for the last couple of days and just figured it out. I had forgotten/didn’t notice to remove a comma that was there in the template provided since I was only running 1 job. The other problem is that I think your “function location”: should be “/updateRegistrations.updateLaRegistrations”,
Incase it helps, another issue that I had was calculating UTC properly. At first I thought UTC and GMT were interchangeable, however GMT does shift an hour for daylight savings whereas UTC never changes.

Thanks for the possible hints. I have run it through a json validator to check for any extra commas and such. That is coming out clean. I’ve also tried a lot of variations of the path with no luck either. ./updateRegistrations.updateLaRegistrations, /updateRegistrations.updateRegistrations, moving it into a folder like the doc such as /utils/updateRegistrations.updateRegistrations.

Watch the Wix youtube video if still struggling.
https://www.youtube.com/watch?v=l9r2SIvKnBM

Thanks for the link. I scanned through the video quick and it seems to be out of date relative to the docs. For example, in the video, it says you should use a jsw module; however, in the latest version of the docs it says you must use .js files. https://support.wix.com/en/article/corvid-scheduling-recurring-jobs

I have tried both jsw and js files along with some of the other setup here.

Is the doc more up to date than the video or is the video the correct source of truth?

Here is a copy of mine, which works. You could try using this and modifying it for yours. I have found that if I put a remark (// or /* */) anywhere after the first “{” then it doesn’t work.

// /backend/jobs.config
{
 "jobs": [
    {
 "functionLocation": "/utilities/jsfilename1.functionname1",
 "description": "update N",
 "executionConfig": {
 "time": "23:00" 
      }
    },
    {
 "functionLocation": "/utilities/jsfilename2.functionname2",
 "description": "update P1",
 "executionConfig": {
 "time": "23:06" 
      }
    },
    {
 "functionLocation": "/utilities/jsfilename3.functionname3",
 "description": "update P2",
 "executionConfig": {
 "time": "23:12" 
      }
    },
    {
 "functionLocation": "/utilities/jsfilename4.functionname4",
 "description": "update final numbers",
 "executionConfig": {
 "time": "23:18" 
      }
    }
  ]
}


Thanks for the help everyone! I finally got one to run. I deleted all of the jobs except for one and took everything I learned from your comments and from the docs and applied it.

It looks like there is some validation happening that we aren’t told about. If any of the jobs are invalid, none of them run. At least based on the evidence I have gathered so far. I was trying to be efficient and run a different type every 15 minutes and I think that’s what bit me.

I definitely recommend adding code to write to a separate table at the start and end of the job so that you can easily see if a job ran or not.

I have put back some additional jobs and will see if those run tomorrow.

Can you post your final jobs.config? I still haven’t had success with it.

Also, instead of writing to two separate tables, you can debug your backend code very easily using the live events monitoring in your dashboard. https://support.wix.com/en/article/corvid-viewing-live-site-events

That live-site-events has been really helpful. Writing to the table was a useful strategy for scheduled events in particular because I could check back later to see if they ran rather than constantly having that live events tab open. I also didn’t have the resources to purchase/setup external logging so I could search back or search later. It’s nice to see exactly when the scheduled job ran and have it permanently logged.

I’ve scrubbed this a bit but here is what eventually worked for me.

{
“jobs”: [
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “915a Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “13:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “1015a Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “14:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “1115a Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “15:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “1215p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “16:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “115p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “17:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “215p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “18:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “315p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “19:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “415p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “20:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “515p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “21:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “615p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “22:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “645p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “22:45”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “715p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “23:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “745p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “23:45”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “815p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “01:15”
}
},
{
“functionLocation”: “/updateRegistrationsJs.updateRegistrations”,
“description”: “915p Get latest registrations from ExternalSystem”,
“executionConfig”: {
“time”: “02:15”
}
}
]
}

Summary of key tips I’ve learned through this process. Note that some may be inaccurate because I don’t have complete data, only some guesses.

  1. Function must be exported from a JS file NOT JSW.
  2. Start with only one event and ensure that works. Even before then, run your function separately by setting up a test page to ensure the function runs without errors from the frontend.
  3. You MUST click PUBLISH, preview will not work for updates
  4. If any job in your file is bad, NONE of the jobs will run
  5. You MUST have fewer than 20 jobs listed or NONE will run
  6. The function location needs to start with a /. The path after that is from your backend directory. E.g., `“functionLocation”: “/updateRegistrationsJs.updateRegistrations” is equal to the path “/backend/updateRegistrationsJs.js” pointing to the exported updateRegistrations function.
  7. Run your jobs.config through a json validator. If any json is invalid NONE of the jobs will run. (e.g., https://jsonlint.com/ )
  8. Even though the code examples show comments, don’t use comments. Remove them all as they are invalid json.
  9. Jobs run on UTC schedule. Google your timezone to UTC to get the time. Use military time (e.g., 21:00)
  10. You can call the same function in multiple jobs, but the descriptions should be unique (this one might just be a guess but seemed to work only after this change, but I didn’t isolate it to confirm)

@nickvhockey13 Got you! That makes sense

@nickvhockey13 that last one may be the clincher! That’s the only one I didn’t try, I had the same description for all test jobs. I’ll try it out, thanks!

@nickvhockey13
Yes that is the question, I would go with the video as that is from August this year.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/video-how-to-execute-timed-tasks-with-the-job-scheduler

Although you would hope that the tutorial page and the video would both be the correct versions to use and they would both relate to each other.

Hopefully somebody from Wix comes back and says that the video for it is still relevant and can be used that way as well as in the actual tutorial for it.
@liorwi @yisrael-wix

Especially as the tutorial states that you have to use js backend files and that you can only do up to the max 20 jobs, whereas the video says that you can use jsw backend files too.

functionLocation (String)

The location of the backend function that will run at the scheduled time. The function can be any function in any backend .js file.

Note:
You can configure up to 20 jobs.

.jsw and .js should be both supported as well as Admin permissions for the database

Copying the list of tips I developed after going through this out here so it isn’t buried in the thread.

https://www.wix.com/corvid/forum/main/comment/5d94d96194a5d5007fcbdc95

Note from @liorwi

@nickvhockey13 Thank you, I got mine worked as well