---
title: StreamEvent
description: "One event off an exec's output stream."
---

One event off an exec's output stream.

One object with a `kind` discriminant rather than three classes, because JS has no
`instanceof` over a union a caller can `switch` on cleanly and the TypeScript idiom is a
tagged union. `kind` is `"output"`, `"gap"`, or `"exit"`, and the fields for the other
two shapes are `null` — which keeps \[`Self::exit_code`] distinguishable from an output
chunk that happens to be last. The absence of an `exit` event is what tells a cut
connection from a finished command; the byte sequences are otherwise identical.

## Properties

### data?

```ts
optional data?: Buffer<ArrayBufferLike>;
```

The bytes, for an output event.

***

### end?

```ts
optional end?: number;
```

One past an output chunk's last byte, or a gap's exclusive end — either way, where a
cursor resumes. `null` on an exit event, whose offset is a *total* rather than a
position, so resuming from it would ask the daemon to replay from the end.

***

### exitCode?

```ts
optional exitCode?: number;
```

***

### kind

```ts
kind: string;
```

`"output"`, `"gap"`, or `"exit"`.

***

### offset?

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

Where an output chunk starts, or where a gap starts.

***

### signal?

```ts
optional signal?: number;
```

***

### stream?

```ts
optional stream?: string;
```

`"stdout"` or `"stderr"`, for an output event. Both share one offset space, so a
caller holds one cursor rather than two that can disagree about ordering.

***

### text?

```ts
optional text?: string;
```

The bytes as text, replacing anything undecodable. `data` is the lossless form.

***

### timedOut?

```ts
optional timedOut?: boolean;
```

Present on exit: whether the remote execution deadline expired.

***

### totalOffset?

```ts
optional totalOffset?: number;
```

Total bytes published, on an exit event.

***

### truncated?

```ts
optional truncated?: boolean;
```

***

### writersMayBeAlive?

```ts
optional writersMayBeAlive?: boolean;
```

## 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.