I currently have a Heroku job set with Scheduler to run my Node application every day at 03:00 UTC. However, I just noticed that it is in fact running every other day with a 'cycling' session occurring regularly in between. The cycling always occurs around the same time (circa ten minutes after my scheduled job) and looks as so:
2020-09-07T03:09:52.819119+00:00 heroku[scheduler.7892]: Cycling
2020-09-07T03:09:52.821074+00:00 heroku[scheduler.7892]: State changed from up to complete
2020-09-07T03:09:54.027852+00:00 heroku[scheduler.7892]: Stopping all processes with SIGTERM
2020-09-07T03:09:54.146349+00:00 heroku[scheduler.7892]: Process exited with status 143
On these days, my application is never launched. Could anyone explain why this is happening...? I suspect something to do with my free dynos and their being re-set somehow on a 24h cycle but I cannot quite wrap my head around what precisely is happening. Note, I am a newbie in coding and hence do not have too much experience, let alone with Heroku's dynos... hence, any detailed explanation would be much appreciated!
** RESOLUTION ** For all those who shall struggle with the same issue: The solution in my case came down to my perpetually open mongoose connection. Because this connection was never actively closed, Heroku's Scheduler was not properly shutting down my application after its scheduled run. In turn, "cycling“, SIGTERM, exiting with status 143 and ultimately dyno shifting ensued; the Schedule's clock was somehow altered and my programme began skipping days. The fix proved straightforward: adding mongoose.disconnect() as the final step (after ensuring the completion of all asynchronous activity) in the script's principal function being executed by Scheduler. Result: my application now runs as desired. :)