Worker Websocket TTL Cleanup
Hello! I'm looking to completely cleanup/delete a durable object once all connections are closed. I tried using an alarm following the exact same alarm code as the TTL example in the docs (https://developers.cloudflare.com/durable-objects/examples/durable-object-ttl/) minus the fetch part. Just defining a 10 minute alarm in the constructor and then an
await this.ctx.deleteAll()
in the alarm function.
Somehow this just results in the alarm being continually triggered once every 10 minutes for all eternity. The alarm never stops, which tells me that the DO is never cleaned up.
My current problem I'm trying to solve is to have a client start a long running async REST API call. This api call returns a transaction id which the webpage then listens to for updates using that specific transaction id (which is a durable object websocket server). The worker eventually has a callback invoked from an external server which lets it know the transaction is complete. This callback event is passed onto the durable object which publishes a message to websocket clients. Once the client receives this message (or the TTL is reached in the case that the callback is never invoked), the server should shutdown and the DO clean up.
Does anyone have any idea why the alarm cleanup method is not working and the alarm keeps triggering?Cloudflare Docs
Durable Object Time To Live · Cloudflare Durable Objects docs
Use the Durable Objects Alarms API to implement a Time To Live (TTL) for Durable Object instances.
0 Replies