Have a huge cron job that runs perfectly when manually triggered, when I execute it as a cron job the cron service returns a status 200 (Success), but … it doesnot do what it is supposed to do. Looked on Stackoverflow, but redirecting output to a file is not possible on Wix Code.
Anyone got any idea how to debug a cron job on Wix Code?
Could it be related to timeout issues? I am using a cron job to scrape data and there are a bunch of loops, so it takes a while to run. It was also returning status 200, but only a portion of the loop was running. I had to chunk the loop. Basically, I made 5 cron jobs to do 1. I have no idea if thats the proper solution, but maybe it helps. Following this post.
David, thanks. The Wix Page takes less than 2 seconds on my slow connection and I came across some message that the default allowance was 6 (over speady lines, Easycron). If I get no other answers, I´ll make a function that writes its results to a collection, see if that helps.
@David Seroy : David, I managed to debug a cron job by writing a small backend function that writes a log entry in a table. Then you just replace all console.log´s with that function . It works. That way I found out that a page runs OK in browser, but not as a cron job: the environment = browser condition is never met. I guess it has to do with something like the cron job not identifying as a browser and the (new) Wix rendering engine skips the environment=browser part. Since Wix no longer answers questions (not only mine, I see Andreas and you running into this too), we are left to our own devices. When you did your cron jobs, did you run into this too? How did you secure the cron job, so that it can not be run by anyone? Wix doesn´t support the username/password authentication by cron jobs and you cannot white list the IP because that´s a “environment = browser” part, but since that is not raised, it´s impossible to get it (only the server IP, which points to Amazon, prob. Wix). I ran out of option to secure a cron job. Any ideas?
@giri-zano Interesting work around. Unfortunately, I don’t have a good answer. I didn’t care much about security for my cron jobs, so this issue never really crossed my mind. Agreed, it is a bit harder to connect directly with the Wix team. Perhaps try DMing one of them directly? Not sure, we have any other options.
Thanks, I´ll give DM a try. Just one caution: ALL pages that you have in that left pane, either marked as Show in menu or not, are listed in the html that is pushed to the browser. If you have named your cron jobs something like “cronjob1” or something alike, it´s not hard to guess which page you could give a try.