connect-bidi-web
    Preparing search index...

    Interface CreateBidiWebSocketHandlerOptions

    interface CreateBidiWebSocketHandlerOptions {
        contextValues?: ContextValues;
        idleTimeoutMs?: number;
        onError?: (error: unknown) => void;
        signal?: AbortSignal;
    }

    Hierarchy

    • HandleMuxedBidiSocketOptions
      • CreateBidiWebSocketHandlerOptions
    Index
    contextValues?: ContextValues

    Context values made available to the handler implementation.

    idleTimeoutMs?: number

    Tears the connection down after this many milliseconds without an incoming frame: in-flight RPCs are aborted and the socket is closed.

    Recommended on pay-per-use runtimes such as Cloudflare Workers, where an idle connection otherwise pins a live invocation until the platform reaps it (and logs the request as hung). Streams that are actively receiving are kept alive by their own traffic; only a fully quiet peer is disconnected. Well-behaved clients dial a fresh connection on their next RPC.

    onError?: (error: unknown) => void

    Called if handleMuxedBidiSocket rejects for a given connection (a bug in a handler implementation; protocol errors are reported to the client instead of throwing). Defaults to a no-op -- the fetch handler never awaits the RPCs, so an unset onError would otherwise surface as a silently swallowed rejection.

    signal?: AbortSignal

    Aborts the in-flight RPC, for example to support graceful server shutdown. Aborting this signal does not close the socket; callers that want the socket closed too should also call close() themselves, or rely on the caller of handleBidiSocket to do so once the returned promise settles.