Skip to content

PopiiTaskDefinition

Popii


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).

TState = any

TPayload = unknown

run(pop, payload?): void | Promise<void>

Defined in: types.ts:464

The function to run. payload is provided when triggered via pop.schedule().

TaskPop<TState>

TPayload

void | Promise<void>

optional name?: string

Defined in: types.ts:448

A unique name for this task. Used when scheduling it via pop.schedule().


optional schedule?: string

Defined in: types.ts:450

Cron expression (e.g. "0 9 * * *" for every day at 9am). Omit for on-demand-only tasks.


optional timezone?: string

Defined in: types.ts:452

Timezone for the cron schedule. Bun’s in-process scheduler currently supports UTC only.


optional payloadSchema?: ZodType<TPayload, unknown, $ZodTypeInternals<TPayload, unknown>>

Defined in: types.ts:454

Runtime schema used to validate manually scheduled and delayed payloads.


optional overlap?: boolean

Defined in: types.ts:456

Allow concurrent runs of this task. Defaults to false (skips if previous run is still active).


optional retries?: number

Defined in: types.ts:458

Number of times to retry on failure. Defaults to 0.


optional retryDelay?: number

Defined in: types.ts:460

Milliseconds to wait between retries. Defaults to 1000.


optional timeoutMs?: number

Defined in: types.ts:462

Maximum execution time in ms before the run is considered timed out.