Diffinery

homeflare/celldpublic

celld/docs/cloudflare-compat.md
477 lines · 23.0 KBRaw History
1# Cloudflare compatibility
2
3celld implements the Cloudflare Workers APIs that this page links to. Read the
4Cloudflare documentation for the standard behavior of each API.
5
6This page lists only an unavailable feature, a celld-specific limit, or an
7observable difference. If an entry has no note, celld intends to match the
8linked Cloudflare API.
9
10- **Yes** means that celld implements the API, except for the listed differences.
11- **Partial** means that a substantial part of the API is unavailable.
12- **Experimental** means that celld can change the API without notice.
13- **No** means that celld does not implement the API.
14
15celld must reject an unsupported configuration or API at deployment or first
16use. An unsupported feature that does not cause an error is a defect.
17
18## Services
19
20| service | status |
21| --- | --- |
22| [Workers](#workers) | **Yes** |
23| [Durable Objects](#durable-objects) | **Yes** |
24| [Durable Object Facets](#durable-object-facets) | **Yes** |
25| [Containers](#containers) | **Experimental** |
26| [Static assets](#static-assets) | **Yes** |
27| [Cron Triggers](#cron-triggers) | **Yes** |
28| [Dynamic Workers](#dynamic-workers) | **Yes** |
29| [KV](#kv) | **Yes** |
30| [Queues](#queues) | **Yes** |
31| [D1](#d1) | **Yes** |
32| [Workflows](#workflows) | **Yes** |
33| [R2](#r2) | **Yes** |
34| Workers AI | **No** |
35| Vectorize | **No** |
36| Hyperdrive | **No** |
37| Browser Rendering | **No** |
38| Email Workers | **No** |
39| Python Workers | **No** |
40
41### [Workers](https://developers.cloudflare.com/workers/runtime-apis/)
42
43- celld does not manage a custom domain or terminate TLS. Terminate TLS in the
44 ingress proxy.
45- celld does not supply a Workers AI binding. Call an AI provider from the
46 application. The process rejects `CELLD_AI_BINDING` and `CELLD_AI_URL`, and a
47 deployment rejects an `ai` declaration.
48
49### [Durable Objects](https://developers.cloudflare.com/durable-objects/)
50
51- A Durable Object event keeps pending I/O active after the handler returns, so
52 a timer or a subrequest does not require `ctx.waitUntil()`.
53- An RPC stub cannot cross an isolate boundary. See [RPC](#rpc).
54- An outbound WebSocket does not continue after the object moves to another
55 node.
56- celld refuses invalid UTF-8 from a SQLite `TEXT` value. Store arbitrary bytes
57 in a `BLOB`.
58- `SqlStorage.Cursor.toArray()` gives a celld-specific error near the V8 heap
59 limit.
60- `storage.sync()` waits for the object store or the fleet ensemble to hold all
61 earlier committed writes. The operation uses the shorter of the 10-second
62 `CELLD_LTX_DURABILITY_TIMEOUT_SECS` default and the 15-second
63 `CELLD_OPERATION_DEADLINE_MS` default.
64- `storage.sync()` rejects during an open transaction and after an object abort.
65 Without an object store, it resolves after the local commit.
66- A transaction and `blockConcurrencyWhile()` have a 30-second limit. A timeout
67 resets the object and rolls back an open transaction.
68- A failed handler still waits for the durability of any value or write that it
69 can expose. A celld-generated failure that exposes no object value returns
70 immediately.
71- Outside an explicit transaction, a SQL write cursor must finish before a
72 response, an outbound effect, or `storage.sync()`. An unfinished `RETURNING`
73 cursor holds uncommitted writes, so celld rejects that output with an error.
74 A read cursor can remain open.
75
76### [Containers](https://developers.cloudflare.com/containers/)
77
78Containers are experimental. The configuration keys, the `ctx.container`
79surface, the node-side defaults, and the security boundary can change
80without notice, and a change appears on this page.
81
82Configuration and images:
83
84- A `containers` entry accepts `class_name`, `image`, `name`,
85 `instance_type`, and `max_instances`. Each other key stops the deployment.
86 The class must be a SQLite-backed Durable Object class of the same script.
87- `image` is a Dockerfile path in the project or an image reference. `celld
88 deploy` and `celld dev` build or pull the image with the `docker` CLI on
89 `PATH`, or the CLI that `CELLD_DOCKER` names. A Podman CLI works.
90- `celld deploy` builds and pulls for `linux/amd64`, as Wrangler does, so a
91 deploy from an ARM machine runs on x86-64 nodes. Set
92 `CELLD_CONTAINER_PLATFORM` to build for another platform. `celld dev`
93 builds for the local machine.
94- `celld deploy` saves each image to the bucket at `deploy/images/<key>.tar`,
95 where the key hashes the image layers and config, so a node never contacts
96 a registry. A node loads an image into its own engine the first time a
97 cell of the class starts, and a redeploy of an unchanged image uploads
98 nothing. The `celld-fence` image that the node needs rides with every
99 deployment that has a container.
100- `instance_type` sets the CPU and memory limits of the Cloudflare instance
101 type with that name. An entry without one gets the `dev` type, a sixteenth
102 of a CPU and 256 MiB, as on Cloudflare. The disk size of the type is not
103 enforced.
104- `max_instances` caps the containers a class runs across the fleet.
105 Cloudflare enforces the cap centrally; celld has no coordinator, so each
106 node publishes its running container count per class in its node record,
107 and a node about to start a container sums that count across the fleet
108 from the shared node sample and adds its own live count. A start over the
109 cap fails, and the object's `monitor()` reports the limit. The sample can
110 lag one refresh, so two nodes that start the same class at once can
111 briefly exceed the cap and converge on the next refresh.
112
113The node and its engine:
114
115- Each node that serves a container class needs a Docker or Podman daemon.
116 celld uses the unix socket that `DOCKER_HOST` names, or the default socket
117 of Docker, Docker Desktop, OrbStack, or Podman. A node without an engine
118 rejects each `start()` with an error, and it serves every other class.
119- `CELLD_CONTAINER_RUNTIME` names the OCI runtime for every container on the
120 node, for example `runsc` for gVisor or `kata` for a virtual machine. A
121 `containers` entry can name a `runtime` of its own, which overrides the
122 node setting for that class; celld adds this key, which Cloudflare's
123 config does not have. The daemon must have the runtime, or every `start()`
124 of a container that names it fails and `monitor()` rejects with the
125 daemon's error, so a class runs only where its isolation exists. Under the
126 default runtime a container is a kernel namespace boundary, not a virtual
127 machine. For code you did not write, set a runtime that gives each
128 container its own kernel, and keep secrets in the Worker, as the Sandbox
129 SDK recommends.
130- A container that runs under a named runtime gets a public resolver in its
131 `/etc/resolv.conf`, `1.1.1.1` by default and the `CELLD_CONTAINER_DNS`
132 resolvers when the operator sets them. gVisor cannot reach the container
133 engine's built-in resolver, so a container under it would resolve no
134 hostname otherwise; the fence permits the public resolver. A container on
135 the node's default runtime keeps the engine's resolver.
136- A container runs on the node that owns the cell. An idle eviction keeps the
137 container running for the `setInactivityTimeout()` window, or for 10
138 minutes without one, and the next activation on the same node reconnects to
139 it. A move to another node, a node restart, and a reset destroy it, so the
140 container disk is ephemeral, as on Cloudflare. A node stop destroys every
141 container of the node, and Ctrl-C on `celld dev` does the same while it
142 keeps the local state.
143
144Every container gets the same limits and the same boundary:
145
146- All Linux capabilities are dropped, `no-new-privileges` is set, the
147 daemon's default seccomp profile applies, and the container can hold 1024
148 processes. Two containers on one node cannot open connections to each
149 other.
150- The node fences its container bridges before the first container starts,
151 with nftables rules on the node, outside every container and every
152 runtime. A container with `enableInternet: true` reaches the Internet and
153 nothing of the node's own: it cannot open a connection to the node, to
154 another node, to the private ranges `10/8`, `172.16/12`, `192.168/16`, and
155 `100.64/10`, or to the link-local range, so the node's internal listener
156 and a cloud metadata service are out of reach. celld installs the rules
157 through the daemon with a one-shot privileged container of the
158 `celld-fence` image. A node that cannot install the rules starts no
159 container, and a deployment from a celld without the fence image starts
160 no container on a node with it. IPv6 bridges are not created, so only IPv4
161 is fenced.
162- `enableInternet: false` attaches the container to an internal bridge with
163 no route out. On macOS the node reaches a container only through
164 published ports, and an internal network publishes none, so `celld dev` on
165 macOS keeps egress on and logs a warning; the fence still applies.
166
167The `ctx.container` surface:
168
169- `running`, `start()`, `monitor()`, `destroy()`, `signal()`,
170 `getTcpPort()`, `exec()`, and `setInactivityTimeout()` work. `start()`
171 accepts `entrypoint`, `env`, `enableInternet`, and `labels`; it ignores
172 `hardTimeout`. `inspect()`, the snapshot methods, and the outbound
173 interception methods reject with an error.
174- A `monitor()` promise and an `exec()` process settle only inside the event
175 that created them. After the handler answers, they do not keep the object
176 active, so a drain can move the object. `running` always reports the
177 engine's state, so an object that lost its `monitor()` sees the exit at
178 its next event. A `start()` that fails is logged by the node as
179 `container_start_failed`.
180- `getTcpPort(port).fetch()` reaches the container over the node's route to
181 it. On Linux the route is the container's bridge address, so every port
182 works. On macOS the route is a published loopback port, so the image must
183 declare the port with `EXPOSE`, as `wrangler dev` requires. A fetch with
184 an `Upgrade: websocket` header gives a 101 response with a `webSocket`,
185 as on Cloudflare.
186- `getTcpPort(port).connect()` gives a socket with the lifetime of the
187 event that opened it. See [TCP sockets](#tcp-sockets).
188
189The published packages:
190
191- `@cloudflare/containers` runs as published. Its `sleepAfter` alarm stops
192 the container, and `getContainer()`, `getRandom()`, and `switchPort()`
193 work.
194- `@cloudflare/sandbox` runs as published on the `cloudflare/sandbox` image:
195 `exec()`, files, processes, sessions, and the code interpreter run inside
196 the container, over the HTTP and the RPC transport. A move of the object
197 to another node stops its container, so the first call after the move can
198 fail with the SDK's `OperationInterruptedError`, as after a container
199 restart on Cloudflare. The next call starts a fresh container. Preview
200 URLs need a wildcard hostname at the operator's load balancer, tunnels
201 run cloudflared inside the container, and bucket mounts use the
202 credentials the application passes. See
203 [`examples/sandbox`](../examples/sandbox).
204
205### [Static assets](https://developers.cloudflare.com/workers/static-assets/)
206
207- celld does not compress an asset response. Use a compressing ingress proxy
208 when a client needs gzip or brotli.
209- celld has no edge cache. Each node keeps a 512 MiB disk cache, configured by
210 `CELLD_ASSET_CACHE_BYTES`, and requires browser revalidation.
211- A node checks the deployment pointer after an asset miss at most once in five
212 seconds.
213- A `_headers` file cannot change `connection`, `content-length`, or
214 `transfer-encoding`.
215- A deployment can contain 20,000 assets, 25 MiB for each asset, and 1 GiB in
216 total. Each `_headers` or `_redirects` file has a 100 KiB limit.
217- `celld deploy` does not read `.assetsignore`. It also refuses a symbolic link,
218 a special file, a non-UTF-8 name, an unsafe decoded path, and a `_worker.js`
219 entry.
220
221### [Cron Triggers](https://developers.cloudflare.com/workers/configuration/cron-triggers/)
222
223- celld rejects a descending range such as `SAT-SUN` and a list that contains
224 `*`.
225- celld runs one handler for each occurrence across the fleet. After downtime,
226 it runs only the most recent missed occurrence.
227- celld serializes the handlers for one script. It retries a failure until the
228 next occurrence unless the handler calls `noRetry()`.
229- A service-binding target cannot run its own Cron Triggers.
230
231### [Dynamic Workers](https://developers.cloudflare.com/dynamic-workers/)
232
233- The process limit is 256 live Dynamic Workers, and each script generation can
234 use 255 slots. Every loader and script shares the process limit.
235- The process rejects the removed `CELLD_MAX_LOADED_WORKERS` environment
236 variable.
237- `getEntrypoint()` and `getDurableObjectClass()` support only the `props`
238 option. A structured-clone encoded `props` value can be at most 1 MiB.
239- A `globalOutbound` Fetcher cannot use `connect()` or a WebSocket.
240- celld rejects `limits`, `tails`, and `allowExperimental`. It does not enforce
241 the `cpuMs` or `subRequests` values inside `limits`.
242- `WorkerCode.env` accepts structured-clone values and Service Binding
243 capabilities. The encoded values and the capability props can total 1 MiB.
244- A loaded Worker entrypoint cannot transfer to another Worker. Awaitable and
245 pipelined properties are also unavailable.
246
247### [Durable Object Facets](https://developers.cloudflare.com/dynamic-workers/usage/durable-object-facets/)
248
249- Facets require Dynamic Workers and a class from a Worker Loader binding. A
250 class from `ctx.exports` or a Durable Object binding is unavailable.
251- Each facet has a separate SQLite database, which celld replicates with the
252 root Durable Object.
253- celld rejects an outbound effect from a facet while a root storage transaction
254 holds an uncommitted facet image.
255- An explicit transaction keeps its uncommitted writes in the facet. A rollback
256 discards those writes, and a commit makes them available for root replication.
257- The `clone()` method is unavailable.
258
259### [KV](https://developers.cloudflare.com/kv/api/)
260
261- celld has no edge cache. `cacheTtl` has no effect, and `cacheStatus` is
262 `null`.
263- A value above 1 MiB requires a fleet bucket.
264- A namespace has one writer. Use more namespaces to increase write capacity.
265
266### [Queues](https://developers.cloudflare.com/queues/configuration/javascript-apis/)
267
268- A queue has one writer. Use more queues to increase write capacity.
269- A Queue owner accepts at most 256 concurrent producer calls. It refuses an
270 additional call, which the producer can retry.
271- celld retains a message for four days. This period is not configurable.
272- Pull consumers, the Queues HTTP API, dashboard controls, manual consumer
273 attachment, R2 event notifications, and Queue event subscriptions are
274 unavailable.
275
276### [D1](https://developers.cloudflare.com/d1/worker-api/d1-database/)
277
278- A binding result can contain at most 100,000 rows or 32 MiB.
279- celld refuses invalid UTF-8 from a SQLite `TEXT` value. Store arbitrary bytes
280 in a `BLOB`.
281
282### [Workflows](https://developers.cloudflare.com/workflows/build/workers-api/)
283
284- celld retains a successful or failed instance for 30 days by default. Each
285 duration in the `retention` option can be at most 30 days.
286- `locationHint` accepts the Cloudflare values, but fleet ownership selects the
287 cell location.
288- Non-step work cannot remain pending for more than 60 seconds.
289- A step result, an event payload, and the workflow parameters each have a
290 1 MiB limit.
291- Rollback, a sensitive step result, and a `ReadableStream` step result are
292 unavailable.
293
294### [R2](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/)
295
296- An R2 binding uses the fleet bucket under `r2/<bucket_name>/`.
297- An object `version` equals its content ETag, so identical content produces
298 the same version.
299- `ssecKey` and `jurisdiction` are unavailable.
300- A conditional write cannot use a streamed body larger than 8 MiB.
301- `createMultipartUpload()` does not accept a checksum.
302- A multipart upload cannot resume on another node or after a restart. celld
303 also cannot replace a part that the object store already holds.
304- Out-of-order parts can use at most 256 MiB of memory, and completion cannot
305 change the stored part order.
306
307## Runtime APIs
308
309| API | status |
310| --- | --- |
311| [Fetch, Request, Response, and Headers](#fetch-request-response-and-headers) | **Yes** |
312| [Bindings](#bindings) | **Yes** |
313| [Context](#context) | **Yes** |
314| [Handlers](#handlers) | **Yes** |
315| [RPC](#rpc) | **Yes** |
316| [Streams](#streams) | **Yes** |
317| Encoding | **Yes** |
318| [WebSockets](#websockets) | **Yes** |
319| [Web Crypto](#web-crypto) | **Yes** |
320| [Web standards](#web-standards) | **Yes** |
321| WebAssembly | **Yes** |
322| [Performance and timers](#performance-and-timers) | **Yes** |
323| Console | **Yes** |
324| [Node.js compatibility](#nodejs-compatibility) | **Partial** |
325| [Cache](#cache) | **Partial** |
326| HTMLRewriter | **Yes** |
327| [TCP sockets](#tcp-sockets) | **Yes** |
328| EventSource | **Yes** |
329| MessageChannel | **Yes** |
330| BroadcastChannel | **No** |
331
332### [Fetch, Request, Response, and Headers](https://developers.cloudflare.com/workers/runtime-apis/fetch/)
333
334- The `cache` request option is unavailable.
335- An inbound `Request` has a `cf` object without Cloudflare edge fields. celld
336 cannot prove the geolocation, colo, or TLS metadata.
337- celld removes `Content-Length` from a Worker response, except for a `HEAD`
338 response.
339- A remote Durable Object call cannot retry after request-body transmission
340 starts because celld keeps no replay copy.
341- A remote Durable Object call waits for a rejected owner generation to change
342 for at most `CELLD_OPERATION_DEADLINE_MS`.
343
344### [Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/)
345
346The [services table](#services) lists the available binding types. Each binding
347type that the table does not list is unavailable.
348
349### [Context](https://developers.cloudflare.com/workers/runtime-apis/context/)
350
351- `passThroughOnException()` has no effect because celld has no CDN fallback.
352- `ctx.facets` is available only inside a Durable Object.
353
354### [Handlers](https://developers.cloudflare.com/workers/runtime-apis/handlers/)
355
356The `tail` and `email` handlers are unavailable.
357
358### [RPC](https://developers.cloudflare.com/workers/runtime-apis/rpc/)
359
360- An RPC stub cannot cross an isolate boundary.
361- An `AbortSignal` in a Durable Object RPC call does not cross a node boundary.
362- A remote RPC retries only when the failed peer attempt did not start the
363 method. Use a stable operation ID for an application retry.
364
365### [Streams](https://developers.cloudflare.com/workers/runtime-apis/streams/)
366
367- celld expires an unclaimed and inactive HTTP stream after 60 seconds. A
368 successful stream operation starts a new 60-second period.
369- An expired or unknown stream reports an error instead of EOF.
370
371### [WebSockets](https://developers.cloudflare.com/workers/runtime-apis/websockets/)
372
373- An outbound Worker socket closes when its event and `waitUntil` work end. A
374 socket returned in the response stays open.
375- Each isolate-polled input queue has a 1 MiB budget for non-terminal frames. A
376 message larger than 1 MiB uses the complete budget.
377- If the isolate stops polling, celld discards unread frames during cleanup. A
378 later pull reports an abnormal close.
379- A WebSocket transport cannot move to a new cell owner. A client must reconnect
380 with the same application operation ID.
381- A tunneled connection forwards the owner's Close without an additional Close.
382 If the owner connection fails between frames before a Close, the ingress sends
383 code 1012. If a frame is incomplete, the ingress closes the transport instead.
384- `acceptWebSocket()` throws above 90 percent of the V8 heap limit.
385
386### [Web Crypto](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
387
388- HMAC accepts MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
389- ECDSA supports only the P-256 curve with SHA-256.
390- AES-GCM accepts authentication tags from 96 through 128 bits in 8-bit steps.
391- RSA-OAEP accepts SHA-1, SHA-256, SHA-384, and SHA-512. A nonempty label must
392 contain valid UTF-8.
393- A secret key cannot use `jwk` with `exportKey()` or `wrapKey()`.
394
395### [Web standards](https://developers.cloudflare.com/workers/runtime-apis/web-standards/)
396
397### [Performance and timers](https://developers.cloudflare.com/workers/runtime-apis/performance/)
398
399`performance.timeOrigin` is `0`, and `performance.now()` matches `Date.now()`.
400Both clocks advance at an I/O boundary and stay fixed during JavaScript
401execution.
402
403### [Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs/)
404
405- celld implements `node:assert`, `node:async_hooks`, `node:buffer`,
406 `node:diagnostics_channel`, `node:events`, `node:fs`, `node:os`, `node:path`,
407 `node:stream`, `node:timers/promises`, and `node:util`.
408- `node:diagnostics_channel` does not export messages to a tail Worker.
409- `node:crypto` does not implement Diffie-Hellman, streaming signatures,
410 ciphers, RSA-PSS, or DSA signatures and key generation.
411- `node:zlib` implements only the synchronous gzip and deflate functions.
412- `node:fs` provides `access`, `mkdir`, `realpath`, `stat`, `lstat`, and
413 `readFile`. It exposes an empty, request-local `/tmp` and a read-only
414 `/bundle` that contains the Worker modules.
415- The celld bundler supports a synchronous CommonJS `require()` of a Node.js
416 built-in module. A raw ESM Worker has no global `require()`.
417- An import of another Node.js module succeeds, but its first call throws an
418 error.
419
420### [Cache](https://developers.cloudflare.com/workers/runtime-apis/cache/)
421
422celld provides an always-miss cache because it has no shared edge cache.
423`put()` validates and consumes a response but stores nothing, `match()` returns
424`undefined`, and `delete()` returns `false`.
425
426### [TCP sockets](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/)
427
428- A socket cannot outlive its event. A Durable Object must reconnect during a
429 later event.
430- celld verifies a TLS server against its bundled Mozilla root store.
431- celld does not block the destination ports that Cloudflare blocks. The fleet
432 network controls the egress policy.
433
434### BroadcastChannel
435
436celld defines the class so that a bundle can load, but its constructor throws an
437error.
438
439## Compatibility flags
440
441celld honors these compatibility switches:
442
443- `delete_all_deletes_alarm`
444- `js_rpc`
445- `fetcher_no_get_put_delete`
446- `sqlite_vec`
447- `websocket_standard_binary_type`
448- The static-assets navigation flags
449
450celld accepts each other compatibility flag without effect.
451`Cloudflare.compatibilityFlags` reports only the flags that celld honors.
452
453## Wrangler configuration
454
455`celld deploy` accepts `wrangler.jsonc` or `wrangler.json`. It does not accept
456`wrangler.toml`.
457
458The `name` value must contain 1 to 63 lowercase ASCII letters, digits, or
459internal hyphens. It cannot start or end with a hyphen.
460
461The deployment accepts these top-level keys:
462
463- `$schema`, `name`, `main`, and `no_bundle`
464- `compatibility_date` and `compatibility_flags`
465- `durable_objects` and `migrations`
466- `assets`, `services`, `triggers`, and `vars`
467- `d1_databases`, `kv_namespaces`, `queues`, `workflows`, and
468 `r2_buckets`
469- `worker_loaders` and `containers`
470
471Each other top-level key, including `routes`, stops the deployment.
472
473An asset-only project can omit `main`. The native deploy command refuses an
474unsafe asset path, and `.assetsignore` requires Wrangler.
475
476See [Limitations](limitations.md) for the operating-system, networking,
477security, pressure, and update boundaries.