---
url: 'https://adk.nht.io/api/@nhtio/adk/batteries/functions/createWorkerTransport.md'
---

# Function: createWorkerTransport()

```ts
function createWorkerTransport(
  spec: IsolatedServiceSpec,
  options: SpawnIsolatedOptions,
): IsolationTransport;
```

Defined in: [src/batteries/isolation/browser.ts:182](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/browser.ts#L182)

Build an [IsolationTransport](../interfaces/IsolationTransport.md) that spawns/re-spawns a real browser `Worker` per [SpawnIsolatedOptions.worker](../interfaces/SpawnIsolatedOptions.md#property-worker).

## Parameters

| Parameter | Type                                                            |
| --------- | --------------------------------------------------------------- |
| `spec`    | [`IsolatedServiceSpec`](../interfaces/IsolatedServiceSpec.md)   |
| `options` | [`SpawnIsolatedOptions`](../interfaces/SpawnIsolatedOptions.md) |

## Returns

[`IsolationTransport`](../interfaces/IsolationTransport.md)

## Remarks

`connect()` resolves the `Worker` (constructing it for a `string | URL` spec, or awaiting a [WorkerResolver](../type-aliases/WorkerResolver.md)), wraps it in a [PortLike](../interfaces/PortLike.md) (`post` → `postMessage` with any @nhtio/adk/batteries/isolation!transfer-marked values unwrapped into the transfer list; `onMessage` →
`addEventListener('message', ...)`), and wires the worker's `'error'`/`'messageerror'` events to the
transport's `onCrash` handlers. `terminate()` calls `worker.terminate()`. `createIsolatedService`'s
`recycle()` re-enters this SAME `connect()` — since a resolver is invoked fresh on every call, it is
the single source of Worker creation for the service's whole lifetime (every respawn goes through it,
never a cached instance).
