kinetex - v1.0.0-rc.1
    Preparing search index...

    Interface SSEClientConfig

    Configuration for creating an SSE client stream.

    interface SSEClientConfig {
        url: string;
        headers?: Record<string, string>;
        fetch?: {
            (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
            (input: string | URL | Request, init?: RequestInit): Promise<Response>;
        };
        signal?: AbortSignal;
        lastEventId?: string;
        reconnect?: boolean;
        reconnectDelayMs?: number;
        maxReconnectDelayMs?: number;
        reconnectJitter?: number;
        maxReconnects?: number;
        onReconnect?: (attempt: number, delayMs: number) => void;
        onParseError?: (err: unknown, raw: string) => void;
        heartbeatTimeoutMs?: number;
        method?: string;
        body?: string | null;
        validateResponse?: (res: Response) => string | boolean;
    }
    Index

    Properties

    url: string

    URL to connect to

    headers?: Record<string, string>

    Additional request headers

    fetch?: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Fetch function (injectable for testing / custom auth)

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    signal?: AbortSignal

    AbortSignal to stop the stream

    lastEventId?: string

    Initial Last-Event-ID to send on first connect

    reconnect?: boolean

    Auto-reconnect on disconnect (default: true)

    reconnectDelayMs?: number

    Initial reconnect delay in ms (default: 3000)

    maxReconnectDelayMs?: number

    Max reconnect delay in ms (default: 30000)

    reconnectJitter?: number

    Jitter factor 0–1 (default: 0.3)

    maxReconnects?: number

    Max reconnect attempts. 0 = infinite (default: 0)

    onReconnect?: (attempt: number, delayMs: number) => void

    Called before each reconnect attempt

    onParseError?: (err: unknown, raw: string) => void

    Called on SSE parse errors

    heartbeatTimeoutMs?: number

    Heartbeat timeout in ms — close if no event received (default: 0 = disabled).

    When the timeout fires:

    1. The reader is cancelled (triggering a stream error)
    2. If reconnect is enabled, the client attempts to reconnect
    3. The onReconnect callback is invoked with the reconnect attempt count

    Use this to detect stale connections that aren't properly closed by the server.

    method?: string

    Request method (default: GET)

    body?: string | null

    Request body (for POST-based SSE)

    validateResponse?: (res: Response) => string | boolean

    Validate response before reading the stream. Return true to accept, false for a generic error, or a string error message.