Skip to content

JobHost

Q extends QueueDefinition<object> = QueueDefinition

new JobHost<Q>(): JobHost<Q>

JobHost<Q>

optional classify(error): FailureKind

Classifies an error a handler threw. Return 'fatal' for errors no retry can fix, and the job fails at once instead of spending its attempts. Without this, only UnrecoverableError is fatal.

unknown

FailureKind


abstract handle(job): Promise<unknown>

Runs one attempt of one job. Return a value to store it as the job’s result.

JobOf<JobsOf<Q>>

Promise<unknown>


optional onFinalFailure(job, error): void | Promise<void>

Called once when a job fails for good (its last attempt threw, or the error was fatal). The place for a per-queue alert or a compensating write. An error thrown here is logged and does not change the job’s outcome.

JobOf<JobsOf<Q>>

unknown

void | Promise<void>