class WebSocketUnavailableError
extends Error
Since 0.1.0

Thrown when a WebSocket route is registered but the application's HTTP adapter provides no upgrade seam, so no handshake could ever succeed.

This happens on a custom third-party IHttpAdapter that predates the setUpgradeRouter seam. First-party adapters for Node, Deno, Bun, and Cloudflare Workers all implement it.

The plugin still registers its service and health indicator in this state, so one codebase deploys everywhere; the failure surfaces at route() — registration time — rather than silently at first connect.

Examples

Example 1

try {
  ws.route('/ws', handlers);
} catch (err) {
  if (err instanceof WebSocketUnavailableError) {
    logger.warn('WebSockets unavailable on this adapter');
  }
}

Constructors

WebSocketUnavailableError(message?: string)

Creates the error.

Parameters
optional
message: string

Optional override for the default explanation

Usage

import { WebSocketUnavailableError } from "websocket-plugin/src/index.ts";