Defjs
Core

WebSocketHandle

Minimal WebSocket instance surface used by the client transport.

@defjs/core · Type

Signature

type WebSocketHandle = Omit<
  WebSocket,
  | "binaryType"
  | "CLOSED"
  | "CLOSING"
  | "CONNECTING"
  | "dispatchEvent"
  | "onclose"
  | "onerror"
  | "onmessage"
  | "onopen"
  | "OPEN"
  | "readyState"
> & { readonly readyState: number };

It is the DOM WebSocket without its event-handler properties, binaryType, dispatchEvent, and the state constants. A custom implementation therefore needs url, protocol, extensions, bufferedAmount, send, close, addEventListener, removeEventListener, and a numeric readyState.

The transport sets binaryType = 'arraybuffer' when the property exists and ignores its absence. If the setter throws, it requests best-effort closure of the constructed handle before failing that attempt with NET_UNREACHABLE; the socket is not left outside cleanup. This property is an optimization, and the decoder also accepts Blob frames. This is the instance type produced by a WebSocketHandleConstructor.

Members

Prop

Type

readyState number
Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao