Thrown into a task's promise when its worker's THREAD ENDED while the task
was in flight — a clean self-termination (process.exit() inside the worker,
or self.close() on runtimes that report it) as much as an abrupt one.
-
code: number | null
The exit code the runtime reported, or
nullwhen it reported none. -
taskModule: string
The task-module specifier the abandoned task belonged to.
The worker pool service registered under CAPABILITIES.WORKER_POOL.
-
run<TInput, TOutput>(): Promise<TOutput>taskModule: string,input: TInput,options?: WorkerRunOptions
Runs a task on the pool for
taskModule, creating it lazily. -
shutdown(): Promise<void>
Shuts down every pool (terminating workers, rejecting pending tasks). Safe to call more than once.
-
stats(): readonly TaskPoolStats[]
Returns a snapshot of every pool created so far.
Thrown by run() when the pool's pending queue is at its bound, shedding
the task instead of growing memory without limit.
-
limit: number
The configured queue bound.
-
taskModule: string
The task-module specifier whose pool queue is full.
Thrown by run() when the task handler threw on the worker, or when the
worker crashed while the task was in flight. Carries the remote error's
serialized shape.
-
remoteName: string
The remote error's
name. -
remoteStack: string
The remote error's
stack, when the worker provided one. -
taskModule: string
The task-module specifier the failing task belonged to.
Thrown by run() when a task exceeds its timeout. The worker running the
task is terminated and replaced — in-flight JavaScript cannot be cancelled.
-
taskModule: string
The task-module specifier the timed-out task belonged to.
-
timeoutMs: number
The timeout that elapsed, in milliseconds.
Creates the WorkerPoolPlugin.
Per-task-module pool overrides, keyed by task-module specifier in
WorkerPoolPluginOptions.pools.
-
maxQueue: number
Pending-queue bound for this pool; overrides the plugin
maxQueue. -
size: number
Workers in this pool; overrides
defaultPoolSize. -
taskTimeoutMs: number
Task timeout in milliseconds for this pool; overrides the plugin
taskTimeoutMs.0disables the timeout.
Options for WorkerPoolPlugin.
-
defaultPoolSize: number
Default workers per pool. Defaults to the host's
availableParallelism(). -
host: IWorkerHost
Injected worker host, taking precedence over the runtime's
IRuntimeServices.workers. Intended for tests and custom transports. -
maxQueue: number
Default pending-queue bound per pool. Defaults to 1024.
-
pools: Readonly<Record<string, TaskPoolOptions>>
Per-task-module overrides, keyed by the specifier passed to
run(). -
taskTimeoutMs: number
Default task timeout in milliseconds. Defaults to 30 000;
0disables. A worker whose task times out is terminated and replaced.
Usage
import * as WorkerPoolPlugin___run_CPU_bound_tasks_on_real_worker_threads_behind_the__CAPABILITIES_WORKER_POOL__capability__Task_modules_register_their_handler_with__defineWorkerTask__from___setu_ts_runtime_worker__and_are_addressed_by_module_specifier___Every_export_is_documented_in_PUBLIC_API_md_ from "worker-pool-plugin/src/index.ts";