Canister timers
One-shot and periodic async timers, driven by the IC global timer and bounded
self-calls. set_timer, set_timer_interval and set_timer_interval_serial
return a TimerId that clear_timer can cancel. The serial variant skips a tick
when its previous invocation is still running.
Pending timers can run after a temporary cycles freeze ends. A declined self-call leaves the timer queued. A retryable callback requeues pending work. Both registration and retry reassert the earliest live deadline, so the cached deadline cannot suppress a wake if the IC has consumed it. The crate owns the physical global timer while its registrations are in use.
When the canister cannot pay for a timer self-call, the due timers stay queued in order and the global timer tries again 60 seconds later. It logs the first declined dispatch of an episode. A deposit does not run Wasm, so funded work resumes at that retry, or at once if the canister was frozen past it. A registration or cancellation that changes the wake retries sooner. Each retried rejection of a timer self-call is logged with its reject code and message.
The global timer handler tracks outgoing self-calls without polling application futures. Timer bodies run in those separate self-call messages. If the global timer handler itself traps and consumes the last wake, a later timer registration can restart the queue. A cycle deposit alone cannot run Wasm in a canister that has lost its only wake.
Recreate transient timer registrations during application restoration. A bounded self-call timeout leaves the occurrence's outcome uncertain. An eligible retry may execute the same occurrence again. Make periodic handler effects idempotent and use an application-owned operation identity when an effect needs deduplication. Only a regular tick schedules a successor. Timer API · SDK upgrade rules