Skip to main content

workers/host/bootHandshake

@arolariu/website


@arolariu/website / workers/host/bootHandshake

workers/host/bootHandshake

Fileoverview

Two-channel bootstrap handshake for the Web Worker host.

Remarks

Owns: building the rpc + event MessageChannel pair, posting the bootstrap message with both ports transferred, attaching the bootstrap- timeout, swapping the event-port listener to steady-state mode after {kind: "ready"} arrives, and exposing a teardown() that closes both parent ports and clears the timeout.

Intentionally NOT owned by this helper:

  • Lifecycle state transitions (bootBegin, bootComplete, crash). The host owns the lifecycle and decides what each handshake outcome means; e.g., a "rejected during boot" outcome may map to either WorkerCrashError (timeout) or WorkerDeadError (host disposed during boot) depending on host-level state the helper does not see.
  • Worker error event listening. The host attaches that listener BEFORE constructing the handshake so an error arriving during boot still triggers the host's handleCrash() path.
  • Comlink wrapping. Callers wrap parentRpcPort themselves once ready resolves.

Type Aliases

Functions

// was this page useful?