Timers and frozen canisters - cryostasis

Reviving this old thread (don’t remember how I happened upon it) to point out that the protocol (i.e. replica) will not (or at least should not) consume a global timer that triggers while the canister is frozen. The timer is retained and will get executed as soon as you top up your canister.

Similarly ic-cdk-timers 1.0.0 goes to great lengths to ensure that every timer is executed exactly once, including if the canister gets frozen while or after the self-call that invokes the callback is made. As far as I (and Claude Code) can tell, the only way in which timers become inactivated is if the ic-cdk-timers code itself traps: the list of CDK timers is retained unchanged; the canister’s GlobalTimer is deactivated (whether the handler execution succeeds or traps; it is only retained on transient errors); and any set_timer with a future deadline will not reactivate the timer.

So to the extent possible, both the protocol and the Rust CDK (at least as of ic-cdk-timers version 1.0.0) do everything possible to ensure “cryostasis” when a canister is frozen. Not sure about Motoko, other Rust CDK versions or third-party libraries.

FWIW, here’s what Claude suggests for debugging the issue:

ic0.global_timer_set returns the previously armed value. Add a query/update that calls it and immediately restores the returned value. That splits the diagnosis cleanly:

  • returns 0 while the timer list is non-empty → CDK/replica desync (panic in ic_cdk_timers), not the freezing threshold;
  • returns a past deadline → the replica is armed and the scheduler is doing its job; the loss is downstream in the CDK;
  • the timer list is empty → the tasks were dropped in canister logic, or the canister was uninstalled.