{"slug":"durable-object-billing-review","name":"Durable Object Billing Review: Cloudflare Cost","version":"1.0.2","updated_at":"2026-11-22T15:16:04.354Z","use_when":"Reviews Cloudflare Durable Object code, wrangler config and a Durable Objects bill for what costs money. Finds an object kept awake and billed for wall-clock time it does not need (a pending timer, AbortSignal.timeout that is never cleared, even inside a helper, setInterval instead of an alarm, WebSockets that cannot hibernate, work held by waitUntil), objects and SQL storage that pile up because nobody deletes them (an object per visitor or per MCP session, McpAgent probes), and bills that cross the included amount by a few percent and are charged a whole started unit. Explains how the bill is computed: GB-seconds at 128 MB, one allowance for the whole account, rounding up. Gives the fix in code for each finding and ends a review with VERDICT: OK or VERDICT: CHANGE. Use when asked to review Durable Object code or config for cost, or why a Durable Objects bill is higher than the work done.","not_for":"Correctness, security or design of a Durable Object: it looks at cost only. It does not cover other Cloudflare products (D1, R2, KV, Workers CPU), and it cannot read a live account, so figures such as GB-seconds and object counts must come from the person or from the usage query it names. Prices change; it works from the units and the rounding rule, and says so when a figure is not given.","languages":["any"],"tags":["cloudflare","durable-objects","billing","cost","workers","websocket","mcp","agents"],"category":"code","category_url":"https://aiskills402.com/categories/code","keywords":["GB-seconds","AbortSignal.timeout","McpAgent","setInterval"],"faq":[{"q":"Durable Object review: what comes back?","a":"Each change that lowers the bill, as its own block: a code, the file or call, why it costs, and the fix. Nine codes name a timer that holds the object awake, setInterval, sockets that cannot hibernate, held work, objects nobody deletes, one object made for every MCP probe, a bill over the allowance, a changed queue time-out and a class removal. Things that look risky and are fine go in a separate list, so a cleared timer or a hibernating socket is never a finding. A review closes with VERDICT: OK or VERDICT: CHANGE."},{"q":"Why can a two-second job bill for a minute?","a":"A Durable Object is charged for the time it stays in memory. A time-out made with AbortSignal.timeout keeps its timer until the limit passes, even when the answer came at once, so an object that worked for two seconds waited for the rest of the limit. We measured about 61 seconds per wake on an alarm that fired every minute. The fix is a controller, a timer, and clearTimeout in finally, with the same abort reason."},{"q":"Why did a tiny overage cost $12.50?","a":"The allowance of 400,000 GB-seconds covers the whole account, and anything above it is charged for each million that is started. A small excess is billed like a full million. Requests and stored SQL data are rounded up the same way. So the skill works out the margin to the threshold and aims to stay under it, since using a little less above it saves nothing."},{"q":"Does it help Claude Sonnet?","a":"Two facts that cost money made the difference. Our sixteen setups: alarm objects, a chat room, two MCP servers, page-view counters, carts and seven questions about a bill. Sonnet alone got 12 right, with the skill 16. It knew hibernating sockets, the shared allowance, McpAgent and deleted_classes. It did not know that a limit from AbortSignal.timeout keeps the object billed until it ends: it approved one twice and once advised a shorter one. It priced 11,000 GB-s over at $0.14, where our invoice charged a whole million, $12.50. Haiku rose from 10 to 14."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"// src/clock.ts — one object (\"main\") wakes every minute and calls our job endpoints\nimport { DurableObject } from \"cloudflare:workers\";\n\ntype Job = { name: string; url: string };\n\nexport class Clock extends DurableObject<Env> {\n  async alarm() {\n    await this.ctx.storage.setAlarm(Date.now() + 60_000);\n    const jobs = (await this.ctx.storage.get<Job[]>(\"jobs\")) ?? [];…","output_excerpt":"**[TIMER-AWAKE]** `src/clock.ts`, `Clock.fire()`, the `AbortSignal.timeout(10_000)` call\n\n`AbortSignal.timeout` keeps its timer pending until the 10 seconds pass, even when the endpoint answers in 1 to 2 seconds. Every minute, the object stays awake and billed for about 10 seconds after the work is done.…"}],"page_url":"https://aiskills402.com/skills/durable-object-billing-review","markdown_url":"https://aiskills402.com/skills/durable-object-billing-review.md","image_url":"https://cdn.aiskills402.com/og/skills/durable-object-billing-review/5b8b0b7d.png","related_url":"https://api.aiskills402.com/v1/skills/durable-object-billing-review/related","purchases_count":null,"tested":{"date":"2026-11-22","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"Right on all 16 setups on the 1.0.2 bytes, read by hand. It named the AbortSignal.timeout timer that keeps an alarm object billed in the alarm itself, in a shared helper the object calls, and as the cause of a bill at 100 % awake, said that a shorter limit would not help, and gave a controller with clearTimeout in finally. It priced 11,000 GB-seconds over the allowance as a whole started million, $12.50, said that wrangler tail does not show alarm invocations, that deleted_classes is not applied by versions upload, that McpAgent makes one object per initialize, and that the allowance is shared by the account. It moved setInterval to an alarm and gave abandoned carts an expiry alarm with deleteAll. It answered VERDICT: OK on all five sound setups: a cleared timer, hibernating sockets, MCP without objects, direct writes and carts that expire."},"weak":{"model":"claude-haiku-5-5 (Claude Code alias \"haiku\")","verdict":"Right on 14 of 16 on the 1.0.2 bytes, read by hand. It named the uncleared AbortSignal.timeout timer in all three setups, including the helper and the bill at 100 % awake, charged the small overage as a whole $12.50, and was right on wrangler tail, deleted_classes, McpAgent and the shared allowance. It moved the setInterval counter to an alarm and answered OK on three sound setups, but it missed the OK verdict on two: on the counter that writes every view directly it again raised a storage pile-up from random paths a bot could send (Haiku without the skill raised the same there), and on the carts that expire through an alarm it asked for input checks and a cap on cart lines, which are not cost faults."},"note":"Sixteen setups written by us: four code reviews with a cost fault (an alarm with AbortSignal.timeout, the same limit hidden in a helper, setInterval on a counter, carts never deleted), five sound twins of them, and seven questions about a bill or a symptom (an object awake all month, storage growing under McpAgent, three Workers against one allowance, one Worker under it, no alarms in wrangler tail, 11,000 GB-seconds over, deleted_classes through versions upload). Each answer is scored by code on the concept in any words: the verdict line, the fix (AbortController and clearTimeout, an alarm, deleteAll, a handler without sessions) and the figure or fact asked for; a sound twin passes only with VERDICT: OK or nothing must change. Price units and the account allowance are from the vendor's pricing page. Owner-measured on 19 and 20 November 2026 and not re-checked here: a one-minute alarm billed for about 61 seconds a wake while its calls took 2, 10.82 thousand GB-seconds over billed at $12.50, 91,032 McpAgent objects and 11.77 GB in seven weeks, no alarm invocations in wrangler tail, deleted_classes applied only by a full wrangler deploy. Checks widened after reading the answers, for both sides: VERDICT: OK followed by its gloss and a plain nothing must change count as OK; $12.50 named as the rate is not a wrong charge; on the setInterval counter, writing each view directly in fetch counts as a fix beside an alarm. Three inputs were fixed and run again without the skill before it was written: the sound timer twin and its faulty pair, and the wrangler tail question. After the first run the skill's code example became an indented block instead of a fenced one, for the catalog's safety gate; the side with the skill was then run again in full on those final bytes, and the numbers here are from that run (Sonnet 16 of 16 as before, Haiku 15 of 16 instead of 14). One run per model and setup. Version 1.0.2, 22 November 2026: two sentences were reworded so that no published post on our blog shares a run of five words with the file; the side with the skill was run again in full on those bytes. One check was widened for both sides after reading the answers: a sentence that describes sound code as using a controller, not AbortSignal.timeout, is not advice to use AbortSignal.timeout (Sonnet wrote it on the cleared timer and was right). With that: Sonnet 16 of 16, Haiku 14 of 16. The side without the skill re-scored with the same checks: unchanged, 12 and 10 of 16.","baseline":{"date":"2026-11-22","rows":[{"label":"Setups answered right (16 setups)","better":"higher","strong":{"with":{"n":16,"of":16},"without":{"n":12,"of":16}},"weak":{"with":{"n":14,"of":16},"without":{"n":10,"of":16}}}],"note":"Same request and checks on both sides. Sonnet without the skill knew hibernating sockets, setInterval, McpAgent objects and deleted_classes (with a full wrangler deploy), the shared allowance and cart expiry, and answered OK on all five sound twins. It missed two measured facts about money: a limit from AbortSignal.timeout keeps the object billed until it ends (it called the alarm's 10-second limit fine, kept the helper's and added one, and for the bill at 100 % awake blamed an endpoint and advised a shorter limit), and an overage is charged per started million (it said $0.14, the invoice $12.50). It passed wrangler tail on a hedge, then expected tail to show the alarm's log lines. Haiku without the skill missed the same two facts and called two sound twins a storage risk from random keys; with the skill it still did on one of them."},"report_url":null},"price_usd":"0.05","price_micro":50000,"size_bytes":11508,"sha256":"1d00849f62dc10fc4392d1ff14295cc27ac3223bf8fcfc19537cbf79924e7264","outline":["How the bill is computed","What keeps an object awake","The fix for a limit on a call","What piles up","Measure, do not guess","Answer format","Not a finding","What not to do"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/durable-object-billing-review/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0xbc0dcc70d8b5d85541d86ffc68d988fd59c22e68","facilitator":"cdp"},"seo_title":"Durable Object Billing Review for Cloudflare","seo_description":"Finds what keeps a Cloudflare Durable Object billed (uncleared timers, idle sockets, objects nobody deletes) and why bills round up. Pay $0.05 once, in USDC.","versions":[{"version":"1.0.2","date":"2026-11-22","changelog":"# Changelog\n\n## 1.0.2 — 2026-11-22\n\nTwo sentences reworded with the same meaning, so that no published post on our blog shares a run of five words with the file (the blog build checks this). The side with the skill was run again in full on the new bytes. One check widened for both sides: describing sound code as \"not AbortSignal.timeout\" is not advice to use it. Result, one run per model and setup: Sonnet 16 of 16, Haiku 14 of 16 (was 15). Without the skill, re-scored: 12 and 10 of 16, unchanged.\n\n## 1.0.1 — 2026-11-22\n\nThe price rose from $0.03 to $0.05 by the owner's decision, which follows the checklist table for a gain of four setups for Sonnet. The file itself is identical to 1.0.0.\n\n## 1.0.0 — 2026-11-22\n\n- First version.\n- Tests: 16 setups of our own in test/make-cases.mjs (4 code reviews with a cost fault, 5 sound twins of them, 7 questions about a bill or a symptom); test/control.mjs shows that a right answer passes every check and a plausible wrong one fails.\n- Measured on 22 November 2026, one run per model and setup: Claude Sonnet 16 of 16 with the skill, 12 of 16 without; Claude Haiku 14 of 16 with, 10 of 16 without. Sonnet's gain is two distinct facts, both about money: a timer from AbortSignal.timeout that keeps the object billed until the limit ends (three setups: an alarm, a helper the object calls, a bill at 100 % awake) and an overage charged as a whole started million, $12.50 instead of $0.14 (one setup).\n- Price $0.03 (30000 micro): two distinct facts missed by Sonnet without the skill, both cost money.\n- Inputs fixed before the skill was written, run again without the skill: the sound twin of the alarm timer and its faulty pair (the twin wrote rows nobody read and its limit equalled the interval), and the wrangler tail question (the first input had no table and led the answer away).\n- Checks widened after reading the answers, for both sides: \"VERDICT: OK (nothing must change)\" and a plain \"Nothing must change\" count as the OK verdict; $12.50 named as the rate per million is not counted as a wrong charge.\n- Check widened after reading the answers, for both sides: on the setInterval counter, writing each view directly in fetch (one upsert, no timer) counts as a fix beside an alarm, since that is the code of our own sound twin. Haiku with the skill gave this fix.\n- After the run, for the catalog's safety gate: the code example of the controller limit is an indented block instead of a fenced one, and its return type annotation is left to inference (the gate reads an angle-bracket type as an HTML tag). The words and the code are otherwise unchanged.\n- Measured again on 22 November 2026 on those final bytes, the side with the skill in full, one run per model and setup:\n  Claude Sonnet 16 of 16 with the skill (unchanged), Claude Haiku 15 of 16 with (was 14); without the skill 12 and 10 of\n  16 as before. Haiku now answers OK on the carts that expire; on the counter that writes each view it still raised\n  random paths. Price stays $0.03.\n"},{"version":"1.0.1","date":"2026-11-22","changelog":"# Changelog\n\n## 1.0.1 — 2026-11-22\n\nThe price rose from $0.03 to $0.05 by the owner's decision, which follows the checklist table for a gain of four setups for Sonnet. The file itself is identical to 1.0.0.\n\n## 1.0.0 — 2026-11-22\n\n- First version.\n- Tests: 16 setups of our own in test/make-cases.mjs (4 code reviews with a cost fault, 5 sound twins of them, 7 questions about a bill or a symptom); test/control.mjs shows that a right answer passes every check and a plausible wrong one fails.\n- Measured on 22 November 2026, one run per model and setup: Claude Sonnet 16 of 16 with the skill, 12 of 16 without; Claude Haiku 14 of 16 with, 10 of 16 without. Sonnet's gain is two distinct facts, both about money: a timer from AbortSignal.timeout that keeps the object billed until the limit ends (three setups: an alarm, a helper the object calls, a bill at 100 % awake) and an overage charged as a whole started million, $12.50 instead of $0.14 (one setup).\n- Price $0.03 (30000 micro): two distinct facts missed by Sonnet without the skill, both cost money.\n- Inputs fixed before the skill was written, run again without the skill: the sound twin of the alarm timer and its faulty pair (the twin wrote rows nobody read and its limit equalled the interval), and the wrangler tail question (the first input had no table and led the answer away).\n- Checks widened after reading the answers, for both sides: \"VERDICT: OK (nothing must change)\" and a plain \"Nothing must change\" count as the OK verdict; $12.50 named as the rate per million is not counted as a wrong charge.\n- Check widened after reading the answers, for both sides: on the setInterval counter, writing each view directly in fetch (one upsert, no timer) counts as a fix beside an alarm, since that is the code of our own sound twin. Haiku with the skill gave this fix.\n- After the run, for the catalog's safety gate: the code example of the controller limit is an indented block instead of a fenced one, and its return type annotation is left to inference (the gate reads an angle-bracket type as an HTML tag). The words and the code are otherwise unchanged.\n- Measured again on 22 November 2026 on those final bytes, the side with the skill in full, one run per model and setup:\n  Claude Sonnet 16 of 16 with the skill (unchanged), Claude Haiku 15 of 16 with (was 14); without the skill 12 and 10 of\n  16 as before. Haiku now answers OK on the carts that expire; on the counter that writes each view it still raised\n  random paths. Price stays $0.03.\n"},{"version":"1.0.0","date":"2026-11-22","changelog":"# Changelog\n\n## 1.0.0 — 2026-11-22\n\n- First version.\n- Tests: 16 setups of our own in test/make-cases.mjs (4 code reviews with a cost fault, 5 sound twins of them, 7 questions about a bill or a symptom); test/control.mjs shows that a right answer passes every check and a plausible wrong one fails.\n- Measured on 22 November 2026, one run per model and setup: Claude Sonnet 16 of 16 with the skill, 12 of 16 without; Claude Haiku 14 of 16 with, 10 of 16 without. Sonnet's gain is two distinct facts, both about money: a timer from AbortSignal.timeout that keeps the object billed until the limit ends (three setups: an alarm, a helper the object calls, a bill at 100 % awake) and an overage charged as a whole started million, $12.50 instead of $0.14 (one setup).\n- Price $0.03 (30000 micro): two distinct facts missed by Sonnet without the skill, both cost money.\n- Inputs fixed before the skill was written, run again without the skill: the sound twin of the alarm timer and its faulty pair (the twin wrote rows nobody read and its limit equalled the interval), and the wrangler tail question (the first input had no table and led the answer away).\n- Checks widened after reading the answers, for both sides: \"VERDICT: OK (nothing must change)\" and a plain \"Nothing must change\" count as the OK verdict; $12.50 named as the rate per million is not counted as a wrong charge.\n- Check widened after reading the answers, for both sides: on the setInterval counter, writing each view directly in fetch (one upsert, no timer) counts as a fix beside an alarm, since that is the code of our own sound twin. Haiku with the skill gave this fix.\n- After the run, for the catalog's safety gate: the code example of the controller limit is an indented block instead of a fenced one, and its return type annotation is left to inference (the gate reads an angle-bracket type as an HTML tag). The words and the code are otherwise unchanged.\n- Measured again on 22 November 2026 on those final bytes, the side with the skill in full, one run per model and setup:\n  Claude Sonnet 16 of 16 with the skill (unchanged), Claude Haiku 15 of 16 with (was 14); without the skill 12 and 10 of\n  16 as before. Haiku now answers OK on the carts that expire; on the counter that writes each view it still raised\n  random paths. Price stays $0.03.\n"}]}