Skip to main content

workers/host/createWorkerHost

@arolariu/website


@arolariu/website / workers/host/createWorkerHost

workers/host/createWorkerHost

Fileoverview

Public factory: a typed Worker host with state machine, telemetry, AbortSignal support, idle reboot, and explicit restart.

Remarks

Composes createWorkerLifecycle, createTelemetryBridge, getCapabilities, and Comlink into the public worker host API.

Two-channel handshake: the host creates two MessageChannels and posts the worker side of each (port2) to the worker via the bootstrap message. rpcPort is wrapped with Comlink.wrap for typed RPC; eventPort carries worker → parent telemetry events. The worker emits {kind: "ready"} on the event port to signal that it is ready for RPC traffic.

Cancellation: AbortSignal is honored on the parent side both when already-aborted at call time and when it aborts mid-flight. Worker-side cancellation (sending a cancel message and aborting the in-worker AbortSignal) is deferred — see the README "Known limitations" section.

Type Aliases

Functions

References

WorkerCapabilities

Re-exports WorkerCapabilities


WorkerEvent

Re-exports WorkerEvent


WorkerCrashError

Re-exports WorkerCrashError


WorkerDeadError

Re-exports WorkerDeadError


WorkerError

Re-exports WorkerError


WorkerMessageError

Re-exports WorkerMessageError


WorkerNotAvailableError

Re-exports WorkerNotAvailableError


WorkerTimeoutError

Re-exports WorkerTimeoutError


WorkerHostState

Re-exports WorkerHostState

// was this page useful?