Skip to content

toolmark-monorepo / @toolmark/core/bridge/websocket / websocketTransport

Function: websocketTransport() ​

websocketTransport(o): BridgeTransport

Defined in: packages/core/src/bridge/websocket.ts:97

WebSocket transport (JSON text frames) using the global WebSocket (Node ≥ 22.12, browsers). Reconnects with exponential backoff (500 ms doubling, capped at maxDelayMs) until a terminal close code, a rejecting onOpen or close(). Non-JSON, binary and oversized (> 4 MiB of text) frames are ignored. The socket opens on the first send or onMessage. A reconnect does not re-send the manifest: the bridge sends one on the next registry revision, and protocol pairing (M3) handles a full resync.

Parameters ​

o ​

WebSocketTransportOptions

Connection options; see WebSocketTransportOptions.

Returns ​

BridgeTransport

A BridgeTransport. send resolves once the frame is written to an open socket; it rejects with Error('buffer overflow') when evicted from the 100-message buffer (oldest first) and with Error('transport stopped') after close() or a terminal stop.

Throws ​

TypeError for an empty url or a non-positive maxDelayMs.