Creating tasks
All three return
Promise<string> — the task id.
ScheduleOptions
id, scheduling is an upsert — the prior task with that id is replaced
and the timer re-armed. Without one, every call creates a new task under a random id.
Dispatch
- A due task calls
this[task.name](task.payload)— one argument, the payload. - If no such method exists, the fallback fires instead:
onTask(name, payload, { attempt }). - Task methods are ordinary methods. A method that should be schedulable but not
RPC-callable from a stub can be named with a leading
_— the runtime excludes_-names from RPC, but the scheduler still dispatches to them.
Failure and retries
- A task that throws is retried with exponential backoff (starting around a second,
capped at 5 minutes), up to
maxRetriestimes after the first delivery — 6 runs total by default. - A task that exhausts its retries is parked: deleted without firing again, and there is no callback when that happens.
- A recurring (
every) task resets its attempt count after each successful run, and schedules its next fire from the start of the drain turn (the timestamp captured before dispatch), not from when the method returns.
Delivery contract
Delivery is at-least-once: a crash after your method runs but before the task is marked done re-runs it on the next activation. Write task handlers to be idempotent — the same rule as alarm handlers. Payloads are stored in the actor’s durable storage and must be codec-safe — JSON-native values plusDate, Map, Set, ArrayBuffer/TypedArray, BigInt, RegExp.
Functions, class instances, or circular references throw a CodecError — see
Errors.