Beignet API reference
    Preparing search index...

    Interface ServerSentEventResponseOptions

    Options for createServerSentEventResponse(...).

    interface ServerSentEventResponseOptions {
        headers?: HeadersInit;
        heartbeatMs?: number | false;
        maxBufferedBytes?: number;
        maxLifetimeMs?: number | false;
        signal?: AbortSignal;
        onError?(error: unknown): void | Promise<void>;
        start(
            stream: ServerSentEventStream,
        ):
            | ServerSentEventCleanup
            | Promise<(ServerSentEventCleanup | undefined)>
            | undefined;
    }
    Index
    headers?: HeadersInit

    Additional response headers such as CORS or Vary.

    heartbeatMs?: number | false

    Interval for SSE heartbeat comments. Defaults to 25 seconds. Set to false to disable heartbeats.

    maxBufferedBytes?: number

    Maximum bytes of unread event data held by the response stream. Defaults to 1 MiB. The connection closes when one frame or the accumulated queue would exceed this limit.

    maxLifetimeMs?: number | false

    Close the connection after this duration so clients can reconnect and reconcile. Disabled by default.

    signal?: AbortSignal

    Abort the stream with the surrounding request or application lifecycle.

    • Observe producer, serialization, buffer, stream, or cleanup failures. Expected AbortError rejections caused by stream closure are ignored.

      Parameters

      • error: unknown

      Returns void | Promise<void>

    • Begin producing events. Return a cleanup callback or closeable subscription for resources associated with this connection. Pending asynchronous setup does not block response cancellation; honor the stream signal and return cleanup when setup settles.

      Parameters

      Returns
          | ServerSentEventCleanup
          | Promise<(ServerSentEventCleanup | undefined)>
          | undefined