PopiiTaskDefinition
Popii / PopiiTaskDefinition
Interface: PopiiTaskDefinition<TState, TPayload>
Section titled “Interface: PopiiTaskDefinition<TState, TPayload>”Defined in: types.ts:446
The definition of a scheduled background task.
Use the task builder function to create one with full type inference.
Tasks are auto-loaded from src/tasks/ and can also be triggered on demand
via pop.schedule("task-name", payload, delayMs).
Type Parameters
Section titled “Type Parameters”TState
Section titled “TState”TState = any
TPayload
Section titled “TPayload”TPayload = unknown
Methods
Section titled “Methods”run(
pop,payload?):void|Promise<void>
Defined in: types.ts:464
The function to run. payload is provided when triggered via pop.schedule().
Parameters
Section titled “Parameters”TaskPop<TState>
payload?
Section titled “payload?”TPayload
Returns
Section titled “Returns”void | Promise<void>
Properties
Section titled “Properties”
optionalname?:string
Defined in: types.ts:448
A unique name for this task. Used when scheduling it via pop.schedule().
schedule?
Section titled “schedule?”
optionalschedule?:string
Defined in: types.ts:450
Cron expression (e.g. "0 9 * * *" for every day at 9am). Omit for on-demand-only tasks.
timezone?
Section titled “timezone?”
optionaltimezone?:string
Defined in: types.ts:452
Timezone for the cron schedule. Bun’s in-process scheduler currently supports UTC only.
payloadSchema?
Section titled “payloadSchema?”
optionalpayloadSchema?:ZodType<TPayload,unknown,$ZodTypeInternals<TPayload,unknown>>
Defined in: types.ts:454
Runtime schema used to validate manually scheduled and delayed payloads.
overlap?
Section titled “overlap?”
optionaloverlap?:boolean
Defined in: types.ts:456
Allow concurrent runs of this task. Defaults to false (skips if previous run is still active).
retries?
Section titled “retries?”
optionalretries?:number
Defined in: types.ts:458
Number of times to retry on failure. Defaults to 0.
retryDelay?
Section titled “retryDelay?”
optionalretryDelay?:number
Defined in: types.ts:460
Milliseconds to wait between retries. Defaults to 1000.
timeoutMs?
Section titled “timeoutMs?”
optionaltimeoutMs?:number
Defined in: types.ts:462
Maximum execution time in ms before the run is considered timed out.