Continuous jobs run on a repeating schedule. Each instance lives in its own Durable Object and maintains persistent state between runs.
Continuous.make(config)
Creates an unregistered continuous job definition. The job name is assigned later via the key you use in createDurableJobs.
ContinuousMakeConfig fields
Effect Schema used to validate and serialize the job’s persisted state. Accepts any Effect Schema —
Schema.Struct, Schema.Class, etc. State is validated on every read and write; invalid state throws ValidationError.When to execute the job. Use
Continuous.every(duration) for fixed intervals or Continuous.cron(expression, tz?) for cron-based schedules. See ContinuousSchedule below.The function to run on each scheduled execution. Must return
Effect<void, E, never> — all service requirements must be satisfied before passing to Continuous.make. If your effect needs services, provide them via .pipe(Effect.provide(layer)).When
true, the job executes once immediately on start before waiting for the first scheduled interval. Set to false to skip the initial run.Automatic retry configuration for
execute failures.Controls the log level for this job’s internal logs.
| Value | Behavior |
|---|---|
false (default) | LogLevel.Error — only failures |
true | LogLevel.Debug — all logs |
LogLevel.Warning | Warnings and above |
LogLevel.None | Silent |
ContinuousSchedule
Two schedule types are supported.
Continuous.every(duration)
Executes the job at a fixed interval measured from the end of the previous run.
duration argument accepts anything that Effect’s Duration.DurationInput accepts — a string such as "5 minutes", a Duration value, or milliseconds as a number.
Continuous.cron(expression, tz?)
Executes the job according to a 6-field cron expression (seconds, minutes, hours, days, months, weekdays). Uses Effect’s built-in Cron module for parsing.
A 6-field cron expression:
seconds minutes hours days months weekdays.Optional IANA timezone name (e.g.,
"America/New_York", "UTC"). Defaults to UTC.ContinuousContext<S>
The context object passed to your execute function on every scheduled run.
| Property | Type | Description |
|---|---|---|
state | Effect<S> | Yields the current persisted state |
setState(s) | (s: S) => Effect<void> | Replaces the entire state |
updateState(fn) | (fn: (s: S) => S) => Effect<void> | Transforms state via a function |
terminate(opts?) | (opts?: TerminateOptions) => Effect<never> | Stops the job and purges all state |
instanceId | string | Full Durable Object instance ID |
jobName | string | Registered job name |
runCount | number | Execution count (1-indexed) |
attempt | number | Current retry attempt (1 = first try) |
isRetry | boolean | true when this is a retry of a previous failure |
Lazily loads the current state from Durable Object storage. Yield it to get the value:
Persists a new state value, completely replacing the current one. The value is validated against
stateSchema before writing.Reads the current state, applies
fn, and writes the result back. More concise than calling setState and state separately.Immediately stops the job: cancels any pending alarm, deletes all state from storage, and short-circuits the current execution. No code after the
yield* runs.The Durable Object instance ID in the format
continuous:{jobName}:{userProvidedId}.The name of the job as registered — matches the key used in
createDurableJobs.How many times
execute has been called for this instance. 1 on the very first run.The retry attempt number within a single scheduled execution.
1 means the first attempt, 2 means the first retry, and so on. Only meaningful when retry is configured.Convenience flag —
true when attempt > 1. Use this to add retry-specific behavior without checking attempt directly.TerminateOptions
An optional human-readable reason for termination. Included in the
job.terminated telemetry event and returned in the terminate response.