Issue with node-cron Jobs behaving differently in different environments

I have a strange issue where I have a chron job that behaves properly in my development environment (ie. it runs once a day at the specified time) but in the production environment it runs every minute. The code is exactly the same (it's reading from the same git repository and commit.) Has anyone run into this problem?
13 Replies
Percy
Percy6mo ago
Project ID: 1432f531-5304-4aa9-8f24-aee5ff595721
Mdchosen
Mdchosen6mo ago
1432f531-5304-4aa9-8f24-aee5ff595721
Brody
Brody6mo ago
in code cron like node-cron or railways cron?
Mdchosen
Mdchosen6mo ago
in code
Brody
Brody6mo ago
then if its an in code schedular that would be an issue with the code while this is super strange and unfortunately i couldn’t tell you why thats happening, it still would be a code issue
Mdchosen
Mdchosen6mo ago
but why would i only see the issue in the production environment but not in the development env. and would you recommend that i use the railways cron instead (not sure how) to avoid this issue
Brody
Brody6mo ago
i honestly have no clue why, but it can only be a code issue though, you are doing an in code schedular, and railway will only ever run your code as is
Mdchosen
Mdchosen6mo ago
is there any chance it could be related to the postgres and redis (i have different ones for the different environments). In other words could be the case that these different data bases are causing different behavior (basically this is the only different between the two environments)
Brody
Brody6mo ago
again, im sorry but i dont have a clue, but you cant rule it out. at the core of this, it would still be a code issue
Mdchosen
Mdchosen6mo ago
k thanks! will continue to trouble shoot and post an answer where if i figure it out in case someone else runs into the same things
Brody
Brody6mo ago
sounds good
Mdchosen
Mdchosen6mo ago
So the issue was actually that the cache in the redis needed to be cleared. This appears to have solved the problem.
Brody
Brody6mo ago
glad to hear it