API Reference/WorkerOptions
interface

WorkerOptions

typescript
interface WorkerOptions<TDefs, TDriver>

Worker options for spawning

Properties

connection(optional)

{ attempts: number; delay: number | (attempt: number) => number; maxDelay: number }

Connection options (child_process driver only).

debug(optional)

boolean

detached(optional)

boolean

Worker lifecycle options

driver(optional)

TDriver

Driver to use for spawning the worker. If not provided, the child_process driver is dynamically loaded. Pass a driver instance for explicit control over the communication backend.

driverOptions(optional)

Partial<DriverOptionsFor<TDriver>>

Driver-specific options. These options are passed directly to the driver's spawn method. Available options depend on the driver being used.

env(optional)

Record<string, string>

Environment variables to pass to worker

logger(optional)

Logger

logLevel(optional)

LogLevel

Logging options

middleware(optional)

Middleware<TDefs>[]

Messaging options

script

string

Path to worker script

serializer(optional)

Serializer

socketPath(optional)

string

Advanced options

spawnOptions(optional)

SpawnOptions

timeout(optional)

number | Partial<Record<BuiltInTimeoutKey | keyof TDefs, number>>

Timeout configuration for worker operations. Can be a number (applies to all operations) or an object with per-operation timeouts: - `WORKER_STARTUP`: Time to wait for worker to start (default: 10s) - `WORKER_MESSAGE`: Default timeout for all messages (default: 5min) - `[messageType]`: Timeout for specific message type (overrides WORKER_MESSAGE)

txIdGenerator(optional)

TransactionIdGenerator<TDefs>

unexpectedShutdown(optional)

UnexpectedShutdownConfig<TDefs>

Unexpected shutdown configuration