# Durable timers need recovery

Principle `durable-timers-need-recovery`. Persist scheduled intent when losing a worker must not lose its deadlines.

Also searched as: durable timer, scheduled-work rehydration.

A crashed server loses timers that existed only in memory. Decide whether to restore scheduled work and identify its durable recovery data.

Book basis: [B3](/bibliography#b3-designing-elixir-systems-with-otp).

## Failure it prevents

A scheduler restarts but pending deadlines silently disappear.

## Our Effect 4.0.5 reading

DurableClock and DurableDeferred cooperate with WorkflowEngine. For an existing storage/alarm owner, keep scheduling in that adapter. A Schedule loop alone is not persistence.

Source: `packages/effect/src/workflow/DurableClock.ts`, `packages/effect/src/workflow/DurableDeferred.ts`, `packages/effect/src/workflow/WorkflowEngine.ts`, `packages/effect/src/Schedule.ts`.

## How to check

Crash before the deadline. Recover it from storage and test both wakeup and cancellation. This is our proposed verification, not a quoted procedure.

Continue with [Durable work needs storage](/principles/durable-work-needs-storage), [Restart must reconstruct known state](/principles/restart-from-known-state).

Connect this to [the existing rat-stack guidance](https://ratstack.sh/lore/lifecycles-are-machines).

Use [the durability skill](/skills/durability) for the full review. Return to [the durability index](/principles/durability).

## Skills
- [Durability starts with a recovery record](/principles/durability)

## Sources
- Gray II, James Edward; Tate, Bruce A. *Designing Elixir Systems with OTP*. Pragmatic Bookshelf, 2019. [Link](https://pragprog.com/titles/jgotp/designing-elixir-systems-with-otp/). ([b3-designing-elixir-systems-with-otp](/bibliography#b3-designing-elixir-systems-with-otp))

## References
- [Effect contributors. Effect 4.0.5. workflow/DurableClock.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/DurableClock.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. workflow/DurableDeferred.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/DurableDeferred.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. workflow/WorkflowEngine.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/WorkflowEngine.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. Schedule.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/Schedule.ts). Pinned source for our Effect mapping, not a claim from the book.
