Skip to content
Back to skills

Cloudflare Durable Objects Knowledge Patch

ASecurity

Cloudflare Durable Objects

  • 25 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 5, 2026
developmentjavascriptpythonjavasqltestingdebuggingapidatabasebackend

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill cloudflare-durable-objects-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cloudflare Durable Objects Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cloudflare Durable Objects Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-cloudflare-durable-objects-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-cloudflare-durable-objects-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cloudflare-durable-objects-knowledge-patch
description: Cloudflare Durable Objects
version: null
license: MIT
metadata:
  author: Nevaberry
---


# Cloudflare Durable Objects knowledge patch

Load this skill when working on Durable Object class lifecycle, identity,
placement, storage, alarms, runtime lifecycle, WebSockets, or tests.
Use the topic references for complete conditions and examples, including
Actors SDK, Python, tracing, spending limits, and Container connections.

## Reference index

| Reference | Topics |
| --- | --- |
| [Deployment and class lifecycle](references/deployment-and-class-lifecycle.md) | Namespace provisioning, `exports`, legacy migrations, rename/delete/transfer, code rollout, spending limits |
| [Identity and placement](references/identity-and-placement.md) | Named and serialized IDs, jurisdictions, placement hints, Actors SDK routing, loopback bindings, delivery retries |
| [Storage, SQL, and recovery](references/storage-sql-and-recovery.md) | SQLite, schema migrations, SQL cursors, transactions, KV APIs, bookmarks, data and alarm deletion |
| [Concurrency, alarms, and runtime lifecycle](references/concurrency-alarms-and-runtime.md) | Initialization, output gates, eviction, shutdown, alarm retries, resets, Dynamic Workers, TCP and Containers |
| [Testing and local development](references/testing-and-local-development.md) | Vitest dependencies and types, test helpers, eviction, local caveats, startup measurement, logs, traces, Preview profiles |
| [WebSocket hibernation](references/websocket-hibernation.md) | Connection limits, tags, attachments, automatic responses, event timeouts, close handling, Python, local support |

## Class lifecycle and deployment gates

- Code exports alone do not provision namespaces. Each provisioned namespace
  needs a live `exports` entry or a tombstone; a live entry must name a class
  exported by the code. Removing both the entry and class fails deployment
  by leaving an orphaned namespace.
- New namespaces declared through `exports` require `sqlite`. Adopt existing
  namespaces with their current backend: `sqlite` for `new_sqlite_classes`,
  `legacy-kv` for `new_classes`. The backend is immutable after provisioning;
  mismatches fail with `storage_type_mismatch`.
- Set `storage` on live and `expecting-transfer` entries; omit it on tombstones.
  Accounts without an existing KV-backed namespace must use SQLite for new
  namespaces; use `new_sqlite_classes` when declaring these with migrations.
- After adopting `exports`, switching back to `migrations` is rejected.
  Omitting both fields reconciles against an empty map. Apply lifecycle
  changes with `wrangler deploy`: `wrangler versions upload` rejects
  configurations with `exports` entries, gradual deployments cannot apply
  these changes, and rollbacks cannot cross an `exports` lifecycle change.
- A new legacy migration also requires `wrangler deploy`;
  `wrangler versions upload` rejects versions introducing a migration.
- For a `deleted` tombstone, remove the class export and local binding.
  Deletion permanently removes the namespace and data once other Workers
  drop their bindings. Resolve `tombstone_delete_blocked_by_external_bindings`
  by redeploying the listed Workers without those bindings first.
- For an `exports` rename, the destination must be live in the same map and
  its name free of a namespace. Delete an occupied destination in a prior
  deploy. Keep both code names exported through the rename rollout, then
  remove the old alias. `tombstone_class_still_in_code` is informational.
- For an `exports` transfer, prepare `expecting-transfer` on the target,
  commit `transferred` on the source while it still ships the class, then
  finalize the target's live entry and local binding after source rollout.
  Follow the reference's handoff sequence and binding updates.
- `stale_tombstone` alone does not mean removal is safe: external bindings
  can still need rename or transfer tombstones. Repoint and redeploy Workers
  in `referencing_scripts`; remove entries listed as `Safe to remove from exports`.
- Named environments inherit top-level `exports` or `migrations` unless
  overridden. Each has its own namespaces, and inherited tombstones act on
  that environment when deployed.

## Storage, initialization, and compatibility changes

- SQLite-backed objects have a 10 GB database limit per object. The general
  availability release deferred migration of existing KV-backed classes.
- `deleteAll()` atomically clears SQLite SQL and KV data; a failed legacy KV
  call can leave keys behind. From compatibility date `2026-02-24`, it also
  clears the scheduled alarm on both backends. On older dates, call
  `deleteAlarm()` separately or opt in with `delete_all_deletes_alarm`.
- Record SQLite schema versions in a table: `PRAGMA user_version` is
  unsupported. The Actors SDK `Storage` wrapper uses increasing
  `idMonotonicInc` values; await `runMigrations()` before its `sql` queries.
- Consecutive SQLite writes without an intervening `await` share an implicit
  transaction. Use `this.ctx.storage.transaction()` for awaited writes that
  must commit together. Direct SQL and KV storage calls participate in the
  enclosing SQLite transaction without using its `txn` argument.
- `ctx.storage.sql.exec()` rejects transaction-control statements, including
  `BEGIN TRANSACTION` and `SAVEPOINT`. Use the storage transaction APIs;
  `transactionSync()` takes a synchronous callback and rolls back if it throws.
- Consume SQL cursors synchronously before awaiting with `cursor.toArray()`
  or `Array.from(cursor)`: resuming later can expose changes made after the
  query started, including writes that may still roll back.
- SQL numeric columns become JavaScript numbers. Select `CAST(id AS TEXT)`
  for exact integers outside the safe integer range.
- `allowUnconfirmed` permits outbound messages while an asynchronous KV write
  is pending. Its `put()` promise can resolve while buffered; await
  `storage.sync()` before sending a message that needs prior writes durable.
- On SQLite, synchronous `ctx.storage.kv` and asynchronous KV APIs share data
  that SQL cannot access, even if `__cf_kv` appears in the table list.
- A deployed SQLite object can restore SQL and KV from a bookmark. Await
  `onNextSessionRestoreBookmark()` and restart; its returned bookmark can undo
  the restore. `getBookmarkForTime()` accepts times within the past 30 days.
- `ctx.blockConcurrencyWhile()` resets the object if its callback exceeds
  30 seconds or an exception escapes. Handle recoverable errors inside the
  callback when the instance can safely continue. Explicitly initiated events
  can still arrive while unrelated events are held.

## Runtime, alarms, and code rollout

- The output gate holds outbound `fetch()` requests and replies until pending
  storage writes commit.
- Eligible objects can hibernate after 10 seconds of inactivity. Scheduled
  timers, awaited `fetch()`, unfinished events, standard WebSockets, and active
  outbound TCP or WebSocket connections prevent hibernation.
- Non-hibernatable idle objects normally evict after 70–140 seconds. Active
  outbound TCP sockets opened with `connect()` and outbound WebSockets defer
  idle eviction for up to 15 minutes per connection; at the cap they remain
  open but stop preventing eviction.
- From compatibility date `2026-10-01`, pending service binding requests,
  RPC or `fetch()` calls to another Durable Object, `this.ctx.container.monitor()`,
  promises passed to `this.ctx.waitUntil()`, and pending `setTimeout()` or
  `setInterval()` timers prevent idle eviction for up to 15 minutes per
  operation. The reference gives opt-in and opt-out flags.
- A plain `fetch()` subrequest body can still be streaming when the object
  becomes eligible for eviction.
- Ownership is checked at event start and storage access. An in-flight HTTP
  or RPC handler on a superseded instance can finish if it avoids storage;
  storage access throws. Runtime updates allow up to 30 seconds to finish,
  and shutdown closes WebSockets. Email and cron follow HTTP shutdown rules.
- `getAlarm()` returns `null` during a running handler unless another alarm
  is scheduled. A failed alarm awaiting retry counts as scheduled.
  `deleteAlarm()` clears a pending alarm while a running handler continues.
- `alarm()` can take an `AlarmInvocationInfo` argument and inspect its
  `retryCount`. Schedule a fresh alarm and return if work remains when retries
  are nearly exhausted; throw earlier failures to use automatic retries.
- `ctx.abort()` resets immediately and logs an `Error` that bypasses
  application `catch` blocks. An in-progress alarm interrupted by `ctx.abort()`
  retries after reset by default. Pass
  `{ retryAlarm: false }` as its second argument on every abort path that
  should suppress retry, including concurrent requests. Local development
  with this option requires Wrangler 4.126.0 or later.
- Active objects can retain current code for up to 300 seconds after deploy
  by default. Hibernation adopts new code on the next request while keeping
  hibernatable WebSockets connected; delay expiry resets the object, and
  runtime updates can reset it sooner. Deferred `max_delay` supports
  0–86400 seconds with millisecond precision.
- Keep Worker and Durable Object RPC interfaces compatible across versions:
  an updated Worker can call an object still running previous code, and skew
  can last throughout a gradual deployment.

## Identity, routing, and delivery retries

- `this.ctx.id.name` exposes names from `idFromName()` or `getByName()`, even
  in alarms. It is `undefined` for `newUniqueId()`, access through
  `idFromString()`, or names longer than 1,024 bytes.
- `idFromString()` throws synchronously for invalid strings or another
  namespace's IDs. Restore IDs through their original namespace binding.
- Jurisdictions produce distinct IDs for the same name. An unscoped namespace
  can open a scoped ID; a differently scoped namespace raises an error.
  The `us` jurisdiction keeps execution and persisted data in the United
  States; calling Workers can access it from anywhere. IDs can appear in
  billing and debugging logs outside the configured jurisdiction.
- `getByName(name, { locationHint })` accepts a best-effort initial placement
  hint. Actors SDK `handler(MyActor)` routes to `"default"`; override static
  `nameFromRequest()` to choose another name and read it with `this.identifier`.
- The runtime automatically retries eligible `fetch()` and RPC delivery failures
  from Workers or other Durable Objects. By default it starts up to four retries
  within 10 seconds of the initial attempt. It skips object-thrown exceptions
  and errors with `.overloaded` set to `true`. If delivery is
  uncertain, the object rejects a retry whose first attempt arrived unless
  an idempotent method is marked with `retryable()` to allow execution again.
- With Wrangler 4.158.0 or later, use `retryable()` and configure a stub's
  `retry` via `get()` or `getByName()`: `maxRetries` is 0–10 and `timeoutMs`
  is 500–60,000. Use `maxRetries: 0` when the caller handles retries.

## WebSocket hibernation

- Each object accepts up to 32,768 hibernatable WebSockets, with up to 10 tags
  of 256 characters each per socket. `getTags(ws)` throws for unattached sockets.
- Attachments store structured-clone snapshots up to 16,384 serialized bytes
  across hibernation for the connection's lifetime. Save changes again with
  `ws.serializeAttachment(value)`; handle `ws.deserializeAttachment()` returning `null`.
  Keep only a storage key if data is larger or must outlive the connection.
- Protocol Ping frames receive Pong without waking the object; control
  frames bypass `webSocketMessage()`. A single `WebSocketRequestResponsePair`
  applies to all hibernatable sockets, with up to 2,048 characters per string.
- WebSocket event timeouts cap event runtime at up to 604,800,000 ms (7 days).
  Pass `0` or omit the timeout argument to clear the limit.
- `web_socket_auto_reply_to_close` defaults on from `2026-04-07`. With it
  disabled, call `ws.close(code, reason)` in `webSocketClose()` to avoid `1006`.
  `ctx.getWebSockets()` can include `CLOSING` sockets; broadcast to those
  whose `readyState` is `WebSocket.OPEN`.
- Local hibernation requires Wrangler 3.13.2 or later and Miniflare 3.20231016.0 or later.
  Earlier versions deliver message events while keeping the object in memory.

## Testing, diagnostics, and operational controls

- The test reference covers `cloudflareTest()` configuration, plugin types,
  Workers test integration dependencies, and `ProvidedEnv` augmentation.
  Use fresh IDs when tests in one file need empty storage: identical IDs
  share persisted writes.
- `runDurableObjectAlarm(stub)` fires a pending alarm immediately and returns
  whether one ran. Test eviction waits up to 30 seconds for requests to drain;
  the same stub then uses a fresh instance with persisted storage intact.
  WebSockets hibernate by default during eviction; `webSockets: "close"`
  closes them. Eviction helpers require `@cloudflare/vitest-pool-workers` 0.16.20 or later.
- `wrangler dev` normally reads storage and keeps writes in memory; an
  explicit binding `script_name` makes writes persistent and triggers a warning.
  Restart the dev process after code edits when testing alarms.
- `wrangler check startup` reports bundle sizes and local CPU from Wrangler
  4.116.0; deploy or upload a version for authoritative startup timing.
- Enabling tail or dashboard logs can replace a running object. WebSocket
  upgrade request logs arrive when the connection closes. Enable
  `[observability.traces]` to collect JavaScript RPC spans across object calls.
- Each Preview has its own namespaces. Use an ID from that Preview when
  profiling one object; the reference includes CPU/heap capture methods.
- Spectrum TCP delivery to `connect(socket, env)` is in public beta. Call
  the Durable Object stub's `connect()`, then connect to the running Container.
  `allowHalfOpen: true` preserves half-closes; the Container terminates TLS
  and handles bidirectional gRPC. The runtime reference includes plan limits.
- Durable Object spend limits are account-wide for the current billing
  period. Turn off **Block usage** for email alerts alone. Reporting and
  blocking can lag, so spend can exceed the limit. The deployment reference
  includes the CLI command and ways to resume blocked operations.

Files in this skill

  • SKILL.md9.1 KB
  • coverage.json1.2 KB
  • references/concurrency-alarms-and-runtime.md3.7 KB
  • references/deployment-and-class-lifecycle.md5.8 KB
  • references/identity-and-placement.md1.9 KB
  • references/storage-sql-and-recovery.md3.3 KB
  • references/testing-and-local-development.md2.7 KB
  • references/websocket-hibernation.md2.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.