StatefulActor is the base class you extend. Subclass it, declare async methods, and they become RPC-callable from a stub. It holds this.ctx (see Actor Context) and this.env (your bindings).
Construction
You don’t construct actors yourself — the runtime does. The base constructor wiresthis.ctx and this.env, so a subclass that doesn’t need init logic can omit its constructor entirely.
ctx.blockConcurrencyWhile — see Actor Context.
Dispatch Rules
- Public methods are RPC-callable from a stub — declare them
async(every stub call is aPromiseon the caller’s side regardless). - Methods whose names start with
_are internal helpers and are not RPC-exposed — the runtime rejects the call. - The
_prefix is the only opt-out. TypeScript’sprivatekeyword is erased at runtime and does not stop remote calls; name internal helpers with a leading_. fetch(req),alarm(info), the constructor, and methods defined onStatefulActoritself (not your subclass) are special and not auto-RPC.- Methods have a wall-clock budget (30s by default). A call that exceeds it fails with
ActorMethodTimeoutError— see Errors.
alarm(alarmInfo)
Optional alarm handler. Override to handle scheduled work. The base implementation is a no-op.
fetch(req)
Optional HTTP-style entry. The base default returns 404. Override if you want callers to reach the actor over a raw Request instead of RPC methods:
env.BINDING.idFromName(name).fetch(req).
Related
- Actor Context —
this.ctx: identity, storage, init - Actor Storage —
this.ctx.storage - Configuration — the
telnyx.tomlactor block