Defjs
Core

SocketAwaitResult

Await-result tuple from opening a WebSocket.

@defjs/core · Type

Signature

type SocketAwaitResult<TIncoming, TOutgoing = never> =
  | [
      error: null,
      socket: WebSocketSession<TIncoming, TOutgoing>,
      connection: WebSocketConnectionInfo,
    ]
  | [
      error: Fault<undefined>,
      socket: undefined,
      connection: WebSocketConnectionInfo | undefined,
    ];
  • On success: [null, session, connection]. session.connection moves forward on reconnect. The tuple's connection preserves the first successful snapshot only for a native Defjs session or a wrapper forwarding the same live connection object. Custom sessions and wrappers that transform connection instead return their current public connection. Sharing closed cannot bypass URL sanitization or metadata filtering, and Defjs does not reconstruct first-connection metadata from arbitrary transformations.

  • On failure: [fault, undefined, connection]. connection may be undefined, for example when the constructor failed before the socket opened.

  • Only startup failures arrive here. Once the session is returned, later errors surface through onRuntimeError, receive, and closed.

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