---
title: SpawnOptions
description: "How a spawn should behave: the exec's own options, plus the stream's."
---

How a `spawn` should behave: the exec's own options, plus the stream's.

Nested rather than flattened onto \[`ExecOptions`], and the reason is that the two sets are
answered by different people. `cwd`/`env`/`user` describe the *child* and are what a caller
composing a command supplies; `offset`/`reconnect`/`gapPolicy` describe how this client
reads the child's output and are what a caller composing a *resume* supplies. Flattening
them would put `maxReconnects` next to `user` in one bag, which is where a caller reaches
for the wrong one.

## Properties

### exec?

```ts
optional exec?: ExecOptions;
```

How to start the child. Identical to `run`'s options, deliberately: `spawn` is a
different view of one exec rather than a different exec.

***

### gapPolicy?

```ts
optional gapPolicy?: GapPolicy;
```

What to do when the daemon reports evicted output. Defaults to `'error'`; see
\[`crate::process`] for why.

***

### idleTimeout?

```ts
optional idleTimeout?: number;
```

How long the body may be silent before the connection is treated as dead, in seconds.

***

### maxReconnects?

```ts
optional maxReconnects?: number;
```

How many reconnects before the streams error. A bound rather than forever.

***

### offset?

```ts
optional offset?: number;
```

The byte to start reading at. Non-zero resumes output a previous process was reading —
which, with a stable `exec.execId`, is how a spawned process survives *this* process
restarting.

#### Default Value

```ts
0
```

***

### reconnect?

```ts
optional reconnect?: boolean;
```

Whether to reconnect after a cut. Defaults to true, and turning it off is what makes a
suspend/resume look like a stream that ended.

## Provenance

This page is generated from `bindings/microvms-js/index.d.ts` by TypeDoc 0.28.20 and typedoc-plugin-markdown 4.13.1, run from `site/scripts/gen-reference.mjs` on every `pnpm run sync`, so an edit made here is overwritten by the next run.

To change the page, change the doc comment in the binding's Rust source, then regenerate the declarations with `mise run dts`. `mise run dts:check` fails when the committed file no longer matches the source.