Interesting topic. I’ve seen missing scheduled events too.
It begs the question, if the cloud is going to (or has) miss a scheduled event, what should the platform do?
Let’s take the types of scheduling that ST can do:
-RunIn
-RunOnce
-Schedule with Cron like functions
and these built in ones:
runEvery5Minutes(handlerMethod)
runEvery10Minutes(handlerMethod)
runEvery15Minutes(handlerMethod)
runEvery30Minutes(handlerMethod)
runEvery1Hour(handlerMethod)
runEvery3Hours(handlerMethod)
All methods do not accumulate, meaning a missed event will not queue up and fire when noticed.
Also, there is about a 20 second window in which a scheduled event will try to run, after that, it purposely dropped.
The issue here is that in all instances, there is no “failed” notification.
We know it didn’t fire, but we don’t know what to do if that occurs.
Essentially all scheduling just dies and doesn’t restart.
App initialization and Update functions don’t fire either at this condition, so no way to jumpstart the schedule… It really boils down to the user having to go into the app and force it.
The challenge is to figure out how to recover from a missed schedule.
The best way is to always use CRON like scheduling as mentioned above, because this seems to recover better than any other methods described.
All other schedule commands or RunIn commands log a DateTime and the system is just checking if it is within a 20 second window after that time to then run the function and then removes itself regardless of success or failure of event handler firing.
Hopefully ST is working on a much more robust scheduling function to exist outside of a SmartApp that can help track down the source of these issues.
More over, someone needs to develop a smarter scheduler that can queue up events within reason or use LIFO or FIFO queuing models to determine state and what needs to fire when the next process cycle occurs to parse scheduled events.
Ultimately, the sandboxing of SmartApps having to all run their own schedules is at fault. Instead, each hub / location instance should have its own scheduling ability and then create schedules within this location “smartapp scheduler” to fire off SmartApp functions.
Anyway, its a fundamental problem. It is plaguing ST as an unreliable system and I think the reality is it is something that has to be fixed beyond just Hub v2, it can be addressed at the cloud level and at a programming issue.
Hope that helps…