method IWorkerPool.run
IWorkerPool.run<TInput, TOutput>(
taskModule: string,
input: TInput,
): Promise<TOutput>

Runs a task on a pool worker for the given task module, creating the pool lazily on first use.

Type Parameters

TInput
TOutput

Parameters

taskModule: string

Module specifier of a task module that calls defineWorkerTask

input: TInput

Structured-clonable task input

optional
options: WorkerRunOptions

Per-call options

Return Type

Promise<TOutput>

The task's structured-clonable output

Throws

WorkerPoolUnavailableError when the runtime has no worker support (e.g. Cloudflare Workers)

WorkerTaskError when the task handler throws or the worker crashes

WorkerTaskTimeoutError when the task exceeds its timeout

WorkerQueueFullError when the pool's pending queue is at its bound

Usage

import { type IWorkerPool } from "common/src/index.ts";