There are several solutions for this running around. They all work off the same basic concept. They
There are several solutions for this running around. They all work off the same basic concept. They store your alarm specifications in DO storage. This can be quite complicated with recurring alarms specified as well as multiple single alarms in the future. The key is that they make sure the next alarm, according to that stored specification, is the one that the single native alarm is setup for. Smart implementations make sure that if you somehow missed an alarm, it'll get caught and executed-maybe a little late, but not missed. They also have retry logic.
The
Internally, we used the PartyKit one for the 5 minutes we were using PartyKit, then we created our own, now we use a fork of Brayden's. I had on my to-do list to release a well-documented stand-alone package that is pluggable based upon Brayden's implementation. I'll move that to the top of the list for Lumenize and you should have something in a day or so.
The
agents package has such a system and it's documented, but unfortunately, you have to adopt the somewhat rickety and spotily-documented Agents ecosystem to use it. There is Brayden's elegant Alarm class but it's not documented, and by default requires your DO extend the Actor base class unless you duplicate what that base class does manually. It's still my favorite implementaion and can be found at @cloudflare/actors on npm. And PartyKit has one as well.Internally, we used the PartyKit one for the 5 minutes we were using PartyKit, then we created our own, now we use a fork of Brayden's. I had on my to-do list to release a well-documented stand-alone package that is pluggable based upon Brayden's implementation. I'll move that to the top of the list for Lumenize and you should have something in a day or so.


