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

# Function: isolateFunction()

```ts
function isolateFunction<A, R>(
  fn: (...args: A) => R | Promise<R>,
  options: IsolateFunctionOptions,
): IsolatedFunctionHandle<A, R>;
```

Defined in: [src/batteries/isolation/isolate\_function.ts:224](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/isolate_function.ts#L224)

Run `fn` inside a throwaway, source-rehydrated Worker. See this module's doc comment for the full
design and the trust-boundary implications of `allowSourceRehydration`.

## Type Parameters

| Type Parameter            |
| ------------------------- |
| `A` *extends* `unknown`\[] |
| `R`                       |

## Parameters

| Parameter | Type                                                                |
| --------- | ------------------------------------------------------------------- |
| `fn`      | (...`args`: `A`) => `R` | `Promise`<`R`>                         |
| `options` | [`IsolateFunctionOptions`](../interfaces/IsolateFunctionOptions.md) |

## Returns

[`IsolatedFunctionHandle`](../interfaces/IsolatedFunctionHandle.md)<`A`, `R`>

## Throws

[E\_ISOLATE\_FUNCTION\_REQUIRES\_SOURCE\_REHYDRATION](../variables/E_ISOLATE_FUNCTION_REQUIRES_SOURCE_REHYDRATION.md) when `allowSourceRehydration` is not
the literal `true`.
