Restate Typescript SDK
    Preparing search index...

    Interface ConnectionOptions

    The ConnectOptions.connection tuning: server discovery, the worker id, reconnect and drain behaviour, HTTP/2 limits, TLS. Every option has a default that fits Restate Cloud; most deployments set none of them.

    interface ConnectionOptions {
        connectionWindowSize?: number;
        connectTimeoutMs?: number;
        drainGraceMs?: number;
        gracefulShutdown?: boolean | { graceMs?: number; signals?: Signals[] };
        handshakeTimeoutMs?: number;
        maxConcurrentStreams?: number;
        maxSessionMemory?: number;
        pingIntervalMs?: number;
        pingMaxMissed?: number;
        pingTimeoutMs?: number;
        reconnectRetryPolicy?: ReconnectRetryPolicy;
        resolveIntervalMs?: number;
        servers?: string[];
        serversSrv?: string;
        signal?: AbortSignal;
        tls?: boolean | ConnectTlsOptions;
        workerId?: string;
    }
    Index

    Properties

    connectionWindowSize?: number

    Per-connection HTTP/2 flow-control window in bytes. Default 16 MiB (Node's 64 KiB default throttles aggregate throughput).

    connectTimeoutMs?: number

    Deadline for establishing the TCP connection and completing the TLS handshake. Default 5_000. Without it, a peer that accepts the connection but never completes TLS would stall reconnection indefinitely.

    drainGraceMs?: number

    How long a draining connection may keep serving its in-flight invocations before being torn down. Default 120_000.

    gracefulShutdown?: boolean | { graceMs?: number; signals?: Signals[] }

    Automatic graceful shutdown on process signals. On by default: the engine installs a one-shot handler for each signal (default SIGTERM) that calls shutdown(). If multiple connections in the same process register for a signal, the shared process-level handler waits for all of them before calling process.exit(0) once draining completes (or the grace elapses) — so an operator-managed deployment gets zero-dropped-invocation rollouts with no wiring. In Kubernetes, set terminationGracePeriodSeconds to at least the drain grace plus the handler slack you want to preserve. The handlers are removed when the connection closes.

    Pass false to opt out entirely — e.g. to manage signals and process exit yourself and call shutdown() by hand. Pass an object to choose the signals and grace, or true for the defaults.

    handshakeTimeoutMs?: number

    Deadline for the handshake with Restate Cloud. Default 5_000, mirroring the server's own handshake timeout.

    maxConcurrentStreams?: number

    Maximum concurrent HTTP/2 streams (in-flight invocations) per connection. Default 4096 (Node's default of 100 is far too low for a deployment serving many concurrent invocations).

    maxSessionMemory?: number

    Node http2 per-session memory cap in MiB. Default 256 (Node's 10 MiB default makes the session reject work under load).

    pingIntervalMs?: number

    Liveness watchdog: send an HTTP/2 PING every this many milliseconds. Default 75_000.

    pingMaxMissed?: number

    Watchdog: consecutive missed PINGs before the connection is declared dead and redialed. Default 2.

    pingTimeoutMs?: number

    Watchdog: how long to wait for a PING ack. Default 10_000.

    reconnectRetryPolicy?: ReconnectRetryPolicy

    Reconnect backoff policy: jittered exponential backoff applied between reconnect attempts (10ms → 120s by default), reset after a stable connection. See ReconnectRetryPolicy.

    resolveIntervalMs?: number

    How often DNS SRV discovery re-resolves the server set. Default 30_000. (The Rust client re-resolves on DNS TTL expiry; Node does not expose record TTLs, so a fixed interval approximates it.) Ignored with explicit server addresses.

    servers?: string[]

    Explicit server addresses, instead of DNS discovery. Each entry is either "host:port" (TLS governed by the tls option) or a URL "https://host:port" / "http://host:port" (scheme selects TLS/plaintext for that server). One connection per entry; the set is fixed (no re-resolution). Private networks and tests.

    At most one of serversSrv and servers may be set.

    serversSrv?: string

    A DNS SRV name to discover the servers to connect to, instead of the one the connect key stands for. For environments with a custom domain; rarely set by hand. Servers are discovered via a DNS SRV lookup expanded to every resolved address — the engine holds one connection per resolved server and re-resolves every resolveIntervalMs, starting connections to servers that appear and tearing down connections to servers that vanish.

    At most one of serversSrv and servers may be set.

    signal?: AbortSignal

    Abort to stop reconnecting and close the connection (same as close()).

    tls?: boolean | ConnectTlsOptions

    TLS for the outbound connection. Default true (system trust, SNI = dialed host, ALPN h2). Pass false only for plaintext dev/test setups, or an object for a private CA / mTLS.

    workerId?: string

    Stable diagnostic identifier for this SDK worker/process. Restate Cloud can include it in routing and failure logs so operators can grep server-side events against SDK-side logs. Defaults to a hostname-based id with a short random suffix that is stable for this process. Advisory only: it is sent in the handshake for diagnostics, not used for authentication.