A Continuous job runs a handler function on a repeating schedule. Each instance runs in its own Durable Object and maintains persistent state between executions. Use Continuous jobs for background work that needs to happen repeatedly: token refresh, health checks, daily reports, and similar patterns.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/backpine/durable-effect/llms.txt
Use this file to discover all available pages before exploring further.
Defining a continuous job
Configuration
Effect Schema for validating and serializing the job’s persistent state. State is validated on every read and write — invalid state throws
ValidationError.When to execute. Use
Continuous.every() for fixed intervals or Continuous.cron() for cron expressions.The function to run on each scheduled tick. Must return
Effect<void, E, never> — all service requirements must be provided via Effect.provide.When
true, the job executes once immediately on start before entering the schedule.Optional retry configuration for
execute failures. When configured, failed executions are retried up to maxAttempts times. Retries are scheduled via durable alarms. When all retries are exhausted, the job is terminated and a job.retryExhausted event is emitted.Control logging verbosity for this job.
false (default) logs only errors. true enables all logs (debug level). Pass a LogLevel value for custom control.Schedule options
Continuous.every(interval)
Execute at a fixed interval. Accepts any Duration.DurationInput.
Continuous.cron(expression, tz?)
Execute on a cron schedule. Uses a 6-field cron format: seconds minutes hours days months weekdays.
The cron format used here is 6 fields (including seconds), not the traditional 5-field format.
Execution context
Thectx object passed to execute provides state access, metadata, and lifecycle control.
| Property | Type | Description |
|---|---|---|
state | Effect<S> | Current state value. Yield to read. |
setState(s) | Effect<void> | Replace the entire state. |
updateState(fn) | Effect<void> | Transform state with a function. |
terminate(opts?) | Effect<never> | Stop the job and purge all state. Short-circuits execution. |
instanceId | string | Unique Durable Object instance ID. |
jobName | string | Job name as registered in createDurableJobs. |
runCount | number | How many times execute has been called (1-indexed). |
attempt | number | Current retry attempt (1 = first try, 2+ = retry). |
isRetry | boolean | Whether this execution is a retry of a previous failure. |
Retry configuration
Terminating a job
Callctx.terminate() from within execute to permanently stop the job. Terminating:
- Cancels any scheduled alarm
- Deletes all state from storage
- Short-circuits the current execution — no code after the call runs
