Can a Durable Object have an alarm for a time in the past that will never fire? #18324
Labels
content:edit
Request for content edits
documentation
Documentation edits
product:durable-objects
Durable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/
Existing documentation URL(s)
https://developers.cloudflare.com/durable-objects/api/alarms/
What changes are you suggesting?
The documentation describes that there is guaranteed at-least-once execution of alarms.
I've experienced situations where
getAlarm()
returns a time in the past, but there are no unhandled errors to be seen and days have past.I'm using a Durable Object as a pseudo long running process by triggering an alarm every 10 seconds. The previous version of my code had a CRON trigger every minute that would check if an alarm was set and if not, would schedule a new alarm (as there should always be an alarm).
That's how I noticed the issue, my DO had been doing nothing all weekend.
getAlarm
was returning a days old alarm time, but it wasn't being triggered.I've now modified my code to also check if the current alarm is greater than a certain time in the past, and if so reset it.
If the system is designed in such a way that an old alarm time will never be triggered (regardless of how that situation arises), then that should be documented. Someone else mentioned they've been experiencing similar issues with alarms set only a short amount of time in the future (less than 10 seconds). Is there an undocumented limitation here?
Sorry if this is a bit of an odd mix of documentation request and bug report, but it feels like there is some undocumented behaviour here.
Additional information
No response
The text was updated successfully, but these errors were encountered: