Defjs
Core

WebSocketState

Lifecycle state of a managed WebSocket session.

@defjs/core · Type

Signature

type WebSocketState =
  | "aborted"
  | "closed"
  | "closing"
  | "connecting"
  | "error"
  | "idle"
  | "open"
  | "reconnecting";
StateMeaning
idleBefore the first connect attempt
connectingPreparing and opening the first connection
openThe physical socket is open
reconnectingPreparing or waiting for a replacement socket after a close
closingClosure was requested with session.close() or disposal
closedTerminal: the session ended without an error or cancellation
abortedTerminal: the session was cancelled through signal
errorTerminal: the session failed, including a startup failure or timeout

Observe it with session.state and session.onStateChange.

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