> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SSE response reference

> Text and JSON events, comments, event IDs, reconnect hints, and remaining execution time.

> [!NOTE]
>
> Generated from the same public contract that feeds the Monaco editor. Declaration-marked deprecated compatibility methods are intentionally excluded. Do not edit this page manually.

This page contains **5 methods**. Search the docs for an exact method name, or use this index:

* [`sse.onDisconnect()`](#sse-onDisconnect)
* [`sse.send()`](#sse-send)
* [`sse.json()`](#sse-json)
* [`sse.comment()`](#sse-comment)
* [`sse.remainingTime()`](#sse-remainingTime)

## `sse.onDisconnect()`

Register one callback for continue-and-notify disconnect policy. Invoked at most once in the same isolate.
Shares the original execution deadline; no extra time is granted. continue skips it and cancel disposes the isolate.
Registration after disconnect still notifies once while execution remains alive. Callback failures appear in diagnostics.
CPU-bound code, a hard timeout or process failure can prevent notification; this is not a durable cleanup guarantee.

### Signature

```ts theme={null}
static onDisconnect(callback: () => void | Promise<void>): void;
```

### Example

```ts theme={null}
sse.onDisconnect(async () => { await api.setInstanceCache('connection-state', { disconnected: true }, 300); });
```

## `sse.send()`

Send text as SSE data. Await for backpressure, not acknowledgement by the receiver.

### Signature

```ts theme={null}
static send(data: string, options?: SseOptions): Promise<void>;
```

### Example

```ts theme={null}
await sse.send('Hello', { event: 'delta', id: '1', retry: 3000 });
```

## `sse.json()`

Serialize JSON and send it as SSE data. Configured automatic terminal event names are reserved; null disables a terminal frame.

### Signature

```ts theme={null}
static json(data: JsonValue, options?: SseOptions): Promise<void>;
```

### Example

```ts theme={null}
await sse.json({ current: 1, total: 10 }, { event: 'progress', id: '1' });
```

## `sse.comment()`

Send a multiline-safe comment. The host also emits automatic heartbeats.

### Signature

```ts theme={null}
static comment(text: string): Promise<void>;
```

### Example

```ts theme={null}
await sse.comment('Working');
```

## `sse.remainingTime()`

Remaining execution budget in milliseconds, never negative.

### Signature

```ts theme={null}
static remainingTime(): number;
```

### Example

```ts theme={null}
const remainingMs = sse.remainingTime();
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.