# Consume native streams

Read incremental SSE events with an explicit lifetime and provider-specific event interpretation.

Canonical: https://searchsdk.dev/docs/guides/streaming
Markdown: https://searchsdk.dev/docs/guides/streaming.md

<a id="events"></a>

## Events are native data

> **TypeScript reference**
> The API names, code and policy behavior in this article describe the TypeScript SDK. See [your language guide](https://searchsdk.dev/docs/sdks) for its supported surface and limits.

**consume.ts · shared stream consumer**

```typescript
import type { NativeSSEEvent } from '@belweave/search-sdk';

export async function consume(events: AsyncIterable<NativeSSEEvent>) {
  for await (const event of events) {
    console.log(event.event, event.id, event.data);
    // Interpret data and terminal/error events using the provider contract.
    // Do not assume every event is JSON or that HTTP 200 means job success.
  }
}
```

An SSE operation resolves to `{ data, metadata }` after response headers. Iterate `response.data` exactly once. `event.data` is a string; `event`, `id`, and `retry` may be present. The parser handles split UTF-8 and CR/LF boundaries, but provider event schemas still require interpretation.

<a id="lifetime"></a>

## Own the stream lifetime

- Pass an AbortSignal to the operation and abort it when the consumer is done.
- Breaking a for-await loop cancels the response body.
- The operation deadline covers the full stream lifetime, including periods when your consumer is idle.
- Response-byte limits apply to the stream as a whole, rather than restarting for each event.

<a id="replay"></a>

## No automatic reconnect or replay

> **Avoid duplicate remote work**
> Once streaming headers are returned, stream consumption is not automatically retried. A disconnect can leave a remote job running. Save job IDs when the provider exposes them and reconcile through documented read operations.

The SSE retry field is preserved as event data. It does not enable EventSource reconnect behavior. An incomplete final event is discarded under the parser's SSE framing rules. Metadata attempts describe connection setup; later iteration errors do not become new HTTP attempts.

- [Native transport reference](https://searchsdk.dev/docs/api/native-transport)
- [Durable job coordination](https://searchsdk.dev/docs/guides/durable-operations)
