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

# Function: serveIsolatedOverPort()

```ts
function serveIsolatedOverPort<S>(
  spec: S,
  factory: IsolatedImplementationFactory<S>,
  port: PortLike,
  options?: ServeIsolatedOptions,
): {
  stop: () => void;
};
```

Defined in: [src/batteries/isolation/serve.ts:90](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/serve.ts#L90)

Serve `spec` over an already-constructed [PortLike](../interfaces/PortLike.md) — the environment-neutral primitive.
Builds the implementation via `factory`, wires a [GuestEndpoint](../classes/GuestEndpoint.md) to it, and announces
readiness (`ready` envelope) once the encoder-availability probe resolves.

## Type Parameters

| Type Parameter                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `S` *extends* [`IsolatedServiceSpec`](../interfaces/IsolatedServiceSpec.md)<[`MethodMap`](../type-aliases/MethodMap.md), [`StreamMap`](../type-aliases/StreamMap.md), [`EventMap`](../type-aliases/EventMap.md)> |

## Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `spec`     | `S`                                                                                        |
| `factory`  | [`IsolatedImplementationFactory`](../type-aliases/IsolatedImplementationFactory.md)<`S`> |
| `port`     | [`PortLike`](../interfaces/PortLike.md)                                                    |
| `options?` | [`ServeIsolatedOptions`](../interfaces/ServeIsolatedOptions.md)                            |

## Returns

```ts
{
  stop: () => void;
}
```

A `stop()` function that tears down the endpoint's port subscription. Does NOT itself close
the port — callers own the port's lifecycle.

| Name     | Type         | Defined in                                                                                                                      |
| -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `stop()` | () => `void` | [src/batteries/isolation/serve.ts:95](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/serve.ts#L95) |

## Throws

@nhtio/adk/batteries/isolation!E\_INVALID\_ISOLATION\_OPTIONS when `options` fails
validation.
