billflare.

Check getAlarm() first and keep preview off real Durable Objects

@graycoin retells the Durable Object alarm loop shared by @shmily7 and draws three habits: check getAlarm() before setAlarm(), do not bind preview environments to real Durable Objects, and reread AI-generated storage and scheduling code.

Products
Durable Objects
Source
Author experience𝕏
Author
@graycoin

Key points

  • The author retells that an unused test project’s Durable Object alarm, written by AI, looped and made about six trillion reads and writes.
  • In his account, the model scheduled another alarm inside runAlarm and reused a checkpoint close to expiry; with a 30-day TTL and a 7-day refresh window, the problem stayed hidden for about three weeks.
  • He frames it as per-use serverless billing meeting self-scheduling code without a circuit breaker, and advises calling getAlarm() before setAlarm(), not binding preview environments to real Durable Objects, and rereading AI-generated storage and scheduling code.
  • Cloudflare’s Alarms API documentation says each Durable Object has one alarm at a time and calling setAlarm() overwrites an existing one; it recommends checking for an existing alarm when setting one in the constructor.

Original sources

  1. Published

    Original post

    Read on 𝕏

    @graycoin retells the Durable Object alarm loop shared by @shmily7 and draws three habits: check getAlarm() before setAlarm(), do not bind preview environments to real Durable Objects, and reread AI-generated storage and scheduling code.

    🔆

    @graycoin · Original 𝕏 post

    Codex,以后我们小心点吧。 一位老哥 1 万刀的 Cloudflare 账单。不是被攻击,不是跑了大流量,是一个没人用的测试项目,Durable Object 的 alarm 被 AI 写成了死循环,读写了 6 万亿次。 Vibe coding 写到一半,模型顺手在 runAlarm 里又排了一次闹钟,还复用了快过期的 checkpoint。TTL 30 天,刷新窗口 7 天,埋了三个星期才炸。账单来的时候已经是五位数,申诉工单是机器人在循环回复,官方说只能“看看”。 这不是倒霉,是 serverless 按次计费碰上没有熔断的自调度代码。以后写 alarm 之前先 getAlarm(),没有才 setAlarm()。预览环境别绑真 Durable Object。AI 生成的存储和调度代码,自己再读一遍。 一万刀买来的教训,比任何教程都贵。
Author experienceWorkers +4

Cloudflare costs $5 a month, but the bill is not capped

不追高 (@Ariella1213) writes an X article explaining that Workers Paid’s $5 is a minimum, that per-product limits and budget alerts do not cap the account bill, and how denial-of-wallet requests, write amplification, delayed stops and background retries add cost.

Smart Shield Argo

v.kleinhenz: Argo costs jumped from $400 to $5,000 a month.

Community user v.kleinhenz says Argo costs for eurekamag.com rose from $400 a month to $5,000 a month, that he turned Argo off, and that Cloudflare does not protect against such a shock charge; in a follow-up he attributes it to bot traffic.

Author experienceDurable Objects +2

Packing always-awake Durable Objects into Containers to cut duration cost

Robert Chandler (@bertie_ai) says keeping 1,000 Durable Objects awake costs $4,050 a month, and that he ran the same 1,000 for $22 a month by pooling them inside Containers with workerd; the thread covers why, the durability trade-off and when real Durable Objects are still cheaper. The figures are the author’s calculations, not a bill.