Skip to main content

Overview

Processor is the async function type that receives jobs and processes them. It’s the core of a Worker’s job processing logic.

Type Definition

Parameters

job

job
Job<T, R, N>
required
The job to be processed

token

token
string
Worker token for the job (used internally for locking)

signal

signal
AbortSignal
Abort signal for job cancellation

Return Value

result
R
The result value that will be stored as the job’s return value

Examples

Basic Processor

Typed Processor

With Progress Updates

With Logging

With Abort Signal

Error Handling

Accessing Job Properties

Parent-Child Jobs

Sandboxed Processors

Processors can also be defined in separate files:

Best Practices

1. Keep Processors Idempotent

2. Use Proper Error Types

3. Handle Long-Running Operations

  • Job - The job class passed to processors
  • Worker - The worker class that runs processors