Deno
此内容尚不支持你的语言。
actor-ts works on Deno, but with caveats. Core actor APIs (Actor, ActorSystem, ActorRef, supervision, etc.) work identically. Subsystems with native dependencies are where support varies.
Status: best-effort
Section titled “Status: best-effort”| Subsystem | Status |
|---|---|
| Core actor API | ✓ Works |
| Cluster transport (TCP) | ✓ Works (via Deno.connect / Deno.listen) |
| Persistence — in-memory | ✓ |
| Persistence — SQLite | ✗ Not supported |
| Persistence — Cassandra | ⚠ Untested |
| HTTP — Fastify | ✓ Works |
| HTTP — Bun.serve | ✗ (Bun-only) |
WebSocket server (websocket() route) | ✓ Works (via Hono backend) |
| Broker actors (Kafka, MQTT, etc.) | ⚠ Depends on Deno-compat of underlying npm package |
For production, we recommend Bun or Node unless your organization is committed to Deno.
Installation
Section titled “Installation”curl -fsSL https://deno.land/install.sh | shdeno --version # need 2.0+Using actor-ts
Section titled “Using actor-ts”// deno.json{ "imports": { "actor-ts": "npm:actor-ts", "ts-pattern": "npm:ts-pattern" }}
// main.tsimport { ActorSystem } from 'actor-ts';
const system = ActorSystem.create('my-app');// ...Deno’s npm-compat lets you import actor-ts directly via npm:
specifiers.
What works out of the box
Section titled “What works out of the box”- Core actor model — Actor, ActorSystem, dispatchers, mailboxes, supervision.
- Cluster transport — Deno’s TCP APIs are wired up.
- In-memory persistence — works for tests + dev.
- DistributedData — pure-JS, works.
- Event stream, receptionist, sharding singleton — all work.
What needs workarounds
Section titled “What needs workarounds”SQLite
Section titled “SQLite”Not supported. Deno doesn’t have a built-in SQLite, and
neither bun:sqlite nor better-sqlite3 work natively.
Workarounds:
deno_sqlite(a Deno-native package) — implementJournalagainst it manually.- HTTP-backed journal — wrap a remote journal service.
- Use Cassandra instead — no SQLite needed for multi-node persistence.
WebSocket server
Section titled “WebSocket server”The websocket() route (backed by a WebsocketServerActor) relies
on the HTTP backend’s upgrade support — @fastify/websocket or ws
on Node, Bun.serve on Bun. On Deno, use the Hono backend
(DenoHonoRunner), which wires up websocket() on top of Deno.serve
Deno.upgradeWebSocketfor you — just installhonowithdeno add npm:hono. No hand-written adapter is needed.
Permissions model
Section titled “Permissions model”Deno’s permission system requires explicit flags:
deno run \ --allow-net \ --allow-read \ --allow-write \ --allow-env \ main.tsFor most actor-ts apps:
--allow-net— cluster + HTTP traffic.--allow-read— config files, certs.--allow-write— for SQLite / file persistence (if using).--allow-env— for env vars.
For production, narrow to specific allowances:
deno run --allow-net=:2552,:8080 \ --allow-read=./reference.conf,./application.conf,./secrets.conf,./.env \ --allow-env=ACTOR_TS_*,DB_PASSWORD main.tsA narrow grant has to name what the config loader touches, because a missing grant is no missing file to Deno — it is a refusal:
--allow-read— the four filesConfig.loadlooks for: the projectreference.conf,application.conf, the secrets file and the.envfile, in the working directory or wherever anACTOR_TS_*variable or the code names them. A file you never ship can stay out of the list only if the code saysfalsefor it (withReferenceConfigFile(false)and its siblings); otherwise startup fails with aConfigErrornaming the file it was refused.--allow-env— theACTOR_TS_*names the loader reads, and every variable a${VAR}in those files names. Deno grants the environment variable by variable, so one left out is refused when the substitution reads it, even when only the.envfile holds it. Measured on Deno 2.6.8.
Deno Deploy
Section titled “Deno Deploy”Deno Deploy is Deno’s edge-style serverless platform. Short-lived isolates, no long-running process — doesn’t fit clustering.
For Deno Deploy use cases:
- Single-actor patterns — spawn one actor per request, then stop.
- Use actor-ts as a library for actor patterns within an HTTP handler, not as a clustering primitive.
Testing on Deno
Section titled “Testing on Deno”import { TestKit } from 'actor-ts/testkit';
Deno.test('counter increments', async () => { const tk = TestKit.create(); // ... await tk.shutdown();});Deno’s built-in test runner works with TestKit.
Migrating to Deno
Section titled “Migrating to Deno”If you’re considering moving from Node / Bun to Deno:
- Verify your peer deps work on Deno — most NPM packages
are usable via
npm:, but a few (especially those with complex native bindings) fail. - Replace SQLite if you use it — switch to in-memory (tests) or Cassandra (production).
- Replace
websocket()routes if used — write a Deno adapter or use SSE instead. - Test cluster formation thoroughly — Deno’s TCP backend has less production hours.
Where to next
Section titled “Where to next”- Runtime overview — the bigger picture.
- Bun — the recommended alternative.
- Node — the other alternative.
- Compatibility matrix — feature-by-feature support.
