Questions about durable object life cycle

Two questions about durable object life cycles …

First, is there a way to force-kill a durable object? I’d like to implement a kill switch that allows us to destroy a durable object if it gets into a bad state. I ask because if an object gets into a bad state it seems like the only way to restart it is to stop sending requests to it… but the worker(s) that call a DO can’t inspect it’s state to know whether or not it’s okay to send it requests.

Second, is there a way to get notified when a DO is about to get evicted from memory and take some action (e.g. saving state to the transactional datastore)? This would be very useful for preserving state across DO incarnations.

Bonus question: Is there a way to get how much time is left until a DO will be evicted? (With the understanding this changes based on how much traffic it’s getting.)

Bringing the answer here from Discord for future readers.

  1. To reset an object you can throw in blockConcurrencyWhile Durable Objects · Cloudflare Workers docs
  2. Not currently. We haven’t added it because it could never be reliable (processes and servers can crash, etc), so we don’t want people to program around it.