| 1 | # Cloudflare compatibility |
| 2 | |
| 3 | celld runs the Workers runtime, with Durable Objects as the stateful |
| 4 | core: module Workers, fetch, JS RPC, service bindings, and static assets. |
| 5 | This page shows that Worker surface, API by API. celld does not run the |
| 6 | rest of the Cloudflare platform, and the scope rule is simple: if |
| 7 | Cloudflare builds a function on Durable Objects, celld can get that |
| 8 | function, and a function on a different primitive is out of scope. |
| 9 | Cloudflare builds D1 on Durable Objects, so a D1 binding is a thin layer |
| 10 | over what celld already has. KV is a global cache with eventual |
| 11 | consistency, and R2 is blob storage: different systems, not on the |
| 12 | roadmap. |
| 13 | |
| 14 | A configuration or binding that is not available must fail loudly, at |
| 15 | deploy or at first use. A silent compatibility gap is a bug; the known |
| 16 | gaps have marks below. |
| 17 | |
| 18 | ## Services |
| 19 | |
| 20 | | service | notes | |
| 21 | | --- | --- | |
| 22 | | **Workers** | Module Workers: `fetch`, JS RPC, service bindings, Durable Object bindings, `vars`. | |
| 23 | | **Durable Objects** | The stateful core. SQLite storage, alarms, inbound hibernatable WebSockets, outbound `ws:`/`wss:` WebSocket clients (constructor and `fetch()` upgrade), one writer for each cell, names as addresses, RPC methods on stubs. | |
| 24 | | **Static assets** | Immutable files, served from the fleet bucket: `assets.directory`, `binding`, `html_handling`, `not_found_handling`, `run_worker_first`, plus `_headers` and `_redirects`. An asset-only project deploys without a Worker. | |
| 25 | | **Worker Loader (Code Mode)** | Experimental. Bind a loader with `CELLD_WORKER_LOADER`. A Worker can then start sandboxed isolates at runtime. See [Dynamic Worker loading](#dynamic-worker-loading-code-mode). | |
| 26 | |
| 27 | Planned: **D1** (a D1 database is a Durable Object with a SQL API; celld |
| 28 | already has the hard part), **Workflows** (durable execution over cells |
| 29 | and alarms), **Queues** (a Durable Object shape; if demand appears). |
| 30 | |
| 31 | A note on durable execution, because the two terms are close. A |
| 32 | durable-execution engine (Temporal, Restate, Azure Durable Functions) |
| 33 | models a process: a sequence of steps that ends. A cell models an |
| 34 | entity: a named unit with state that persists indefinitely. You can |
| 35 | build either primitive on the other — Cloudflare builds Workflows on |
| 36 | Durable Objects — so choose the one that matches the shape of the |
| 37 | problem. A concert, a user, and a document are entities; an order |
| 38 | pipeline is a process. |
| 39 | |
| 40 | Not planned: **KV** (a different consistency model), **R2** (celld runs |
| 41 | *on* blob storage; celld does not provide blob storage; declared |
| 42 | `r2_buckets` bindings load, but each method throws), **Cache API**, |
| 43 | **Workers AI, Vectorize, Hyperdrive, Browser Rendering, Email** (managed |
| 44 | platform services; an experimental HTTP adapter for an AI binding exists |
| 45 | behind `CELLD_AI_URL`), **cron triggers, custom domains, TLS |
| 46 | termination** (platform surface; celld has its own durable alarms; put |
| 47 | TLS in your ingress proxy). |
| 48 | |
| 49 | ## Runtime APIs |
| 50 | |
| 51 | Cloudflare's [Runtime APIs |
| 52 | index](https://developers.cloudflare.com/workers/runtime-apis/), category |
| 53 | by category: |
| 54 | |
| 55 | | API | status | |
| 56 | | --- | --- | |
| 57 | | Fetch, Request, Response, Headers | **Yes.** Gaps: `Response.redirect()`, `Response.error()`, and the `cache` request option are missing. | |
| 58 | | Bindings (`env`) | **Yes** for Durable Objects, service bindings, `vars`, assets. Other binding types are out of scope (see Services). | |
| 59 | | Context (`ctx`) | **Yes**: `waitUntil`, `props`, `exports`. `passThroughOnException()` is accepted but has no effect. There is no CDN behind it. `ctx.facets` is absent (see Facets). | |
| 60 | | Handlers | `fetch`, `alarm`, `webSocketMessage`/`Close`/`Error`, RPC methods. **No** `scheduled` (cron), `queue`, `tail`, or `email` handlers. | |
| 61 | | RPC | **Yes**, for most of the surface. See [RPC](#rpc). | |
| 62 | | Streams | **Yes.** This includes byte streams, BYOB readers, `tee`/`pipeTo`/`pipeThrough`, `IdentityTransformStream`, `FixedLengthStream`, and `CompressionStream`/`DecompressionStream`. Gap: `ReadableStream.from()`. | |
| 63 | | Encoding | **Yes**: `TextEncoder`/`TextDecoder` (legacy encodings included), encoder and decoder streams, `atob`/`btoa`. | |
| 64 | | WebSockets | **Yes**, inbound (hibernatable, with attachments) and outbound. An attachment holds anything that structured clone accepts. Auto-response works: `setWebSocketAutoResponse` answers a matched message without a wake of the cell. Gap: `getTags()`. | |
| 65 | | Web Crypto | **Partial**: `digest` (including MD5), HMAC sign and verify, AES-GCM, RSA-OAEP decrypt, Ed25519 and ECDSA-P256 sign, and `verify` for RSASSA-PKCS1-v1_5 and ECDSA-P256 (RS256 and ES256 JWTs). `importKey` and `exportKey` handle `spki`, `pkcs8`, `jwk` and `raw` for RSA, EC (P-256, P-384, P-521), Ed25519 and X25519, validating at import; keys cross to `node:crypto` through `KeyObject.from()`. `generateKey` covers AES, HMAC, RSA (OAEP, PKCS#1 v1.5, PSS), EC P-256 and Ed25519. Cloudflare's extensions `timingSafeEqual` and `DigestStream` (with CRC32, CRC32C and CRC64-NVME) are available. AES-CBC, AES-CTR and AES-GCM (12- or 16-byte IVs). ECDH `deriveBits` and `deriveKey` on P-256, P-384 and P-521. Missing: `wrapKey`/`unwrapKey`, RSA-PSS *signing*, HKDF and PBKDF2 through `deriveBits` (they are available through `node:crypto`). An algorithm that is not available throws. | |
| 66 | | Web standards | **Yes**: `URL`, `URLSearchParams`, `URLPattern`, `AbortController`/`AbortSignal` (with `timeout()`, `any()`; a signal does **not** abort across an RPC call, and `signal.onabort` is accepted but never invoked — use `addEventListener('abort')`), `Blob`/`File`/`FormData`, `Event`/`EventTarget`, `DOMException`, `queueMicrotask`, `structuredClone` (not conformant on exotic types), `navigator.userAgent`. | |
| 67 | | WebAssembly | **Yes** (V8's own, without restrictions). A bundle can import a `.wasm` file as a compiled module, as on Cloudflare; see [WebAssembly](wasm.md). | |
| 68 | | Performance and timers | `setTimeout`/`clearTimeout`, `setImmediate`, `scheduler.wait()`. `setInterval` throws. `performance.now()` has millisecond resolution. The other parts of `performance` are stubs. | |
| 69 | | Console | `log`/`info`/`warn`/`error` are real. `debug`/`trace`/`group`/`table` do nothing. `assert`/`time`/`count` are absent. | |
| 70 | | Node.js compatibility | **Partial.** See [node: imports](#node-imports). | |
| 71 | | Facets (`ctx.facets`) | **No.** A Durable Object cannot create a facet, and `ctx.facets` is not defined. celld also has no first-class `DurableObjectClass` value, so `ctx.exports` gives no stub for a Durable Object class that the configuration does not declare. | |
| 72 | | Cache (`caches`) | **No.** | |
| 73 | | HTMLRewriter | **No.** | |
| 74 | | TCP sockets (`cloudflare:sockets`) | **No.** Known silent gap: `connect()` currently gives an inert stub. It does not throw. | |
| 75 | | EventSource, MessageChannel, BroadcastChannel | **No.** The classes exist so that bundles load, but they do nothing. | |
| 76 | |
| 77 | ## RPC |
| 78 | |
| 79 | celld implements the Workers [JS RPC |
| 80 | system](https://developers.cloudflare.com/workers/runtime-apis/rpc/): |
| 81 | `WorkerEntrypoint` and `RpcTarget` from `cloudflare:workers`, named |
| 82 | entrypoints on service bindings, and method calls on Durable Object stubs |
| 83 | (this needs `extends DurableObject`, or the `js_rpc` compat flag). |
| 84 | Arguments and returns use structured clone. Functions, streams, and |
| 85 | `RpcTarget`s become stubs. Promise pipelining, `ctx.exports` loopback |
| 86 | stubs, and stubs in DO storage are available. `ctx.exports` covers the |
| 87 | entrypoints that the configuration declares, so it gives no stub for an |
| 88 | undeclared Durable Object class. |
| 89 | |
| 90 | The current limits: a cross-isolate service binding with a named |
| 91 | entrypoint can do single method calls, but not `fetch()`, awaitable |
| 92 | properties, or pipelined paths; a same-isolate binding has the full |
| 93 | surface. |
| 94 | |
| 95 | A stub cannot cross an isolate boundary yet, and a Durable Object is its |
| 96 | own isolate. A Durable Object method therefore takes and returns |
| 97 | structured-cloneable values. If you pass a function to one, or return an |
| 98 | `RpcTarget` from one, the call throws `RPC stubs cannot cross isolate |
| 99 | boundaries yet`. Callbacks, `RpcTarget` instances and promise pipelining |
| 100 | all work through `ctx.exports`, which shares the isolate. The |
| 101 | [`rpc` example](https://github.com/denoland/celld/tree/main/examples/rpc) |
| 102 | shows each of these. |
| 103 | |
| 104 | ## Dynamic Worker loading (Code Mode) |
| 105 | |
| 106 | Set `CELLD_WORKER_LOADER=LOADER`. Workers then get `env.LOADER`. This is |
| 107 | an experimental port of Cloudflare's [Worker |
| 108 | Loader](https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/). |
| 109 | `loader.get(name, getCode)` (memoized) and `loader.load(code)` start a |
| 110 | new isolate for each loaded worker. These inputs are honored: |
| 111 | `mainModule`, sibling `modules`, `compatibilityDate`/`Flags`, plain-JSON |
| 112 | `env`, and `globalOutbound: null` (no egress). The limits of workerd |
| 113 | apply: 64 MiB of code and 1 MiB of env, plus the |
| 114 | `CELLD_MAX_LOADED_WORKERS` limit. A loaded worker serves `fetch()` and |
| 115 | single RPC method calls. Not yet available: `globalOutbound` as a |
| 116 | Fetcher, capability stubs in `env`, awaitable or pipelined properties. |
| 117 | |
| 118 | ## node: imports |
| 119 | |
| 120 | `node:` specifiers are always available; the `nodejs_compat` flag is not |
| 121 | necessary, and celld does not read it. `celld deploy` externalizes |
| 122 | `node:*` at bundle time. The runtime supplies its own subset (it does not |
| 123 | use the Wrangler-style unenv polyfills): |
| 124 | |
| 125 | - **Implemented**: `node:assert`, `node:async_hooks` (a real |
| 126 | `AsyncLocalStorage`), `node:buffer`, `node:events`, `node:path`, |
| 127 | `node:stream` (+ `stream/web`, `stream/promises`, `stream/consumers`), |
| 128 | `node:timers/promises`, `node:util`. |
| 129 | - **Partial**: `node:crypto` (hashes, HMAC, HKDF, PBKDF2, `webcrypto`, secret |
| 130 | key objects, asymmetric keys, and one-shot signatures. `createPublicKey` and |
| 131 | `createPrivateKey` read PEM, DER and JWK for RSA, EC (P-256, P-384, P-521), |
| 132 | Ed25519, X25519 and DSA, including password-protected PKCS#8, and give a key |
| 133 | with `asymmetricKeyType`, `asymmetricKeyDetails`, `toCryptoKey()` and |
| 134 | `export()` to DER, PEM or JWK. `generateKeyPairSync` covers RSA, EC P-256, |
| 135 | Ed25519 and X25519. `sign()` and `verify()` cover Ed25519, RSA PKCS#1 v1.5 |
| 136 | and ECDSA P-256, with DER signatures as Node's `dsaEncoding` default |
| 137 | requires. What still throws: Diffie-Hellman throughout, the streaming |
| 138 | `createSign`/`createVerify`, ciphers, RSA-PSS, DSA signing, and key |
| 139 | generation for DSA and DH), `node:zlib` (only the sync `gzip`/`deflate` |
| 140 | family), `node:fs` (reads fail with `ENOENT`, `existsSync` is `false`). |
| 141 | - **Not implemented**: the rest — `node:http(s)`, `node:net`, |
| 142 | `node:tls`, `node:dns`, `node:os`, `node:process` (the `process` |
| 143 | global exists, the module does not), `node:worker_threads`, `node:vm`, |
| 144 | `node:child_process`, and the others. Known silent gap: these |
| 145 | currently give inert stubs. They do not fail the import. |
| 146 | |
| 147 | ## Compatibility flags |
| 148 | |
| 149 | `compatibility_date` and `compatibility_flags` are honored for the |
| 150 | switches that celld models: `delete_all_deletes_alarm`, `js_rpc`, |
| 151 | `fetcher_no_get_put_delete`, `websocket_standard_binary_type`, and the |
| 152 | assets navigation behavior. `Cloudflare.compatibilityFlags` reports only |
| 153 | the flags that celld honors. A flag that celld does not model is absent |
| 154 | rather than reported as enabled, and celld accepts it without effect. |
| 155 | |
| 156 | ## Wrangler configuration |
| 157 | |
| 158 | `celld deploy` builds a standard Wrangler project (esbuild on `PATH`) |
| 159 | and accepts `wrangler.jsonc` or `wrangler.json`, not `wrangler.toml`. |
| 160 | The available config keys are `name`, `main`, |
| 161 | `compatibility_date`, `compatibility_flags`, `durable_objects`, |
| 162 | `migrations`, `assets`, `services`, and `vars`. An asset-only project can |
| 163 | omit `main`. celld refuses symlinks and special files in the asset |
| 164 | directory, and `.assetsignore` still needs Wrangler. Each other key — |
| 165 | `routes`, `kv_namespaces`, `triggers`, and the rest — stops the deploy |
| 166 | with an error that names the key: remove the key, or deploy that project |
| 167 | with Wrangler. |
| 168 | |
| 169 | This page is the reference for the implemented Worker surface. For the |
| 170 | operational boundaries of the current release — TLS, platforms, pressure |
| 171 | shedding, updates — see the [limitations](limitations.md). |