[]previous and next page

StreamOptions

Limits of the stream routes.

Limits of the stream routes. Every value has a default; a value out of range is refused at startup.

Import#

ts
import type { StreamOptions } from "@shadow-js/dusk/server";

Signature#

ts
interface StreamOptions {
  /** Milliseconds between the heartbeat comments of an SSE stream. Default 15 000. */
  readonly sseHeartbeatMs?: number;
  /** Sends that may wait at once for a slow SSE consumer before the stream is closed. Default 256. */
  readonly sseMaxBufferedEvents?: number;
  /** Largest WebSocket message a client may send, in bytes. Default 1 MiB. */
  readonly wsMaxMessageBytes?: number;
  /** WebSocket messages a client may send per second. Default 100. */
  readonly wsMaxMessagesPerSecond?: number;
  /** Milliseconds between the server's WebSocket pings. Default 30 000. */
  readonly wsPingIntervalMs?: number;
  /** Milliseconds a ping may wait for its pong. Default 10 000. */
  readonly wsPongTimeoutMs?: number;
  /**
   * Message handler calls that may be in flight at once on one WebSocket connection (a `message` handler that
   * returns a promise that has not settled). The next message closes the connection with 1013 and is not
   * handled. Handlers that return synchronously never count. Default 16.
   */
  readonly wsMaxInFlightMessages?: number;
  /**
   * Upgraded WebSocket connections one client address may hold at once (the address `trustProxy` resolves;
   * an IPv6 client counts by its /64). The next upgrade is refused with 503 and `Retry-After` before a socket
   * exists. `false` turns the cap off. Default 100. Behind a proxy, set `trustProxy`, or every client shares
   * the proxy's address.
   */
  readonly wsMaxConnectionsPerAddress?: number | false;
  /**
   * Upgraded WebSocket connections the whole handler may hold at once (the bookkeeping of the per-address
   * cap is bounded by it). The next upgrade is refused with 503 and `Retry-After`. `false` turns the cap off.
   * Default 10 000.
   */
  readonly wsMaxConnections?: number | false;
}

Members#

Name Type Description
sseHeartbeatMs? readonly sseHeartbeatMs?: number Milliseconds between the heartbeat comments of an SSE stream. Default 15 000.
sseMaxBufferedEvents? readonly sseMaxBufferedEvents?: number Sends that may wait at once for a slow SSE consumer before the stream is closed. Default 256.
wsMaxMessageBytes? readonly wsMaxMessageBytes?: number Largest WebSocket message a client may send, in bytes. Default 1 MiB.
wsMaxMessagesPerSecond? readonly wsMaxMessagesPerSecond?: number WebSocket messages a client may send per second. Default 100.
wsPingIntervalMs? readonly wsPingIntervalMs?: number Milliseconds between the server's WebSocket pings. Default 30 000.
wsPongTimeoutMs? readonly wsPongTimeoutMs?: number Milliseconds a ping may wait for its pong. Default 10 000.
wsMaxInFlightMessages? readonly wsMaxInFlightMessages?: number Message handler calls that may be in flight at once on one WebSocket connection (a message handler that returns a promise that has not settled). The next message closes the connection with 1013 and is not handled. Handlers that return synchronously never count. Default 16.
wsMaxConnectionsPerAddress? readonly wsMaxConnectionsPerAddress?: number | false Upgraded WebSocket connections one client address may hold at once (the address trustProxy resolves; an IPv6 client counts by its /64). The next upgrade is refused with 503 and Retry-After before a socket exists. false turns the cap off. Default 100. Behind a proxy, set trustProxy, or every client shares the proxy's address.
wsMaxConnections? readonly wsMaxConnections?: number | false Upgraded WebSocket connections the whole handler may hold at once (the bookkeeping of the per-address cap is bounded by it). The next upgrade is refused with 503 and Retry-After. false turns the cap off. Default 10 000.