I’m having trouble with
running a backend scheduled job through jobs.config which times out after 59 seconds because it hasn’t finished (which I believe is the limit for a backend job even on a Premium plan).
Working in
Wix Studio - I don’t need to share the code as its not a code issue….
What I’m trying to do
I have a lot of experience in Velo so, bear with me this is more troublesome than it seems.
I have a client site (Premium) with a CMS table with 116 rows (varies by day). These are properties. Each property has a media gallery that has between 1 and 25 images in a media gallery. So potentially a lot of images…
I need to run a scheduled job overnight that generates XML data for each property. This is for a 3rd party site like Zoopla. Don’t worry about the format etc that’s not the issue here. Ordinarily ,1 single scheduled job could trawl through the 116 rows and spit out the XML (function included in the scheduled job). Would probably take 30 seconds at most - so well within the 59 second limit.
However as WiX holds the image URLs as internal wix: format URLs, I need to make a backend call ( from the backend scheduled job) to the media library getDownloadUrl() function. No problem. Works just fine.
However, as that call is not the fastest - I only get to process about 7-10 of the 116 rows before 59 second have elapsed and the scheduled job dies !?!
Because 59 seconds is a limit I have read about for a backend function on multiple threads. And of course scheduled jobs run in the backend so is killed after 59 seconds.
Simples I thought. I’ll schedule the job to run every minute for 30 minutes…. but each time it would be able to pick up from where the last job stopped (knowing how many rows have been successfully output to XML so far….). No problem in testing, works a treat when running from the front end. But from the backend - it seems you cannot repeat a scheduled job unless it’s 1 hour after the last ???
So I now have a simple job running on the hour from 8pm to 6am to get 59 seconds worth of grunt with 11 attempts over 11 hours.
Has anybody else had this issue with scheduled jobs where you have a data function that takes more than 59 seconds?
Is 59 seconds per backend job a thing for a Premium plan ?
Is a 1 hour gap between scheduled jobs a restriction people are also working around ? ( I know its in the documentation that its 1 hour)
Any workarounds anyone has tries ?
I thought of auto generating the downloadable URL for each image when I store the images in ythe first place (then never have to call the getDownloadURL at all from the backend scheduled job) but the downloadable URL has a time to live of 1 year - which would create a ticking time bomb for properties that don’t change in a year !. Also, it creates significantly more maintenance when adding, removing images etc in the front end
Any help appreciated. I do have a ticket in progress too.
thank you in advance.
