moeru-ai/airi · error · Error

WebSocket transport is not implemented for node runtime yet.

Error message

WebSocket transport is not implemented for node runtime yet.

What it means

Thrown by createPluginContext() in the node runtime adapter when transport.kind is 'websocket'. The node runtime only implements the 'in-memory' transport; the websocket branch is an explicit not-yet-implemented guard rather than silent acceptance.

Source

Thrown at packages/plugin-sdk/src/plugin-host/runtimes/node/index.ts:29

/**
 * Creates the Eventa context used by node-side extension host sessions.
 *
 * Use when:
 * - Bootstrapping a node runtime extension session
 *
 * Expects:
 * - `transport` describes a transport supported by the node runtime
 *
 * Returns:
 * - A node-compatible Eventa context, or throws if the transport is not implemented
 */
export function createPluginContext(transport: PluginTransport): EventContext<any, any> {
  switch (transport.kind) {
    case 'in-memory':
      return createContext()
    case 'websocket':
      throw new Error('WebSocket transport is not implemented for node runtime yet.')
    case 'node-worker':
      throw new Error('Node worker transport is not implemented yet.')
    case 'electron':
      throw new Error('Electron transport is not implemented yet.')
    case 'web-worker':
      throw new Error('Web worker transport is not available in node runtime.')
    default:
      throw new Error('Unknown plugin transport kind.')
  }
}

View on GitHub (pinned to 27111382b4)

Solutions

  1. Use { kind: 'in-memory' } for node-runtime plugin contexts until websocket support ships.
  2. If websocket is required, run the host in an environment whose runtime adapter implements it, or contribute an implementation for the node adapter.
  3. Gate transport selection on the runtime so node never receives a websocket transport.

Example fix

// before
const ctx = createPluginContext({ kind: 'websocket', url: 'ws://localhost:8080' })

// after
const ctx = createPluginContext({ kind: 'in-memory' })
Defensive patterns

Strategy: validation

Validate before calling

if (transport.kind === 'websocket') {
  throw new Error('WebSocket transport is not implemented for the node runtime. Use in-memory.')
}
const ctx = createPluginContext(transport)

Type guard

function isImplementedNodeTransport(transport: PluginTransport): boolean {
  return transport.kind === 'in-memory'
}

Try / catch

try {
  ctx = createPluginContext(transport)
} catch (error) {
  if (error instanceof Error && /WebSocket transport is not implemented for node/.test(error.message)) {
    ctx = createPluginContext({ kind: 'in-memory' })
  } else {
    throw error
  }
}

Prevention

When it happens

Trigger: Calling createPluginContext({ kind: 'websocket', url, protocols }) on the node runtime. The PluginTransport union allows this kind, but the node adapter has no implementation for it.

Common situations: A plugin host configured for node attempts to use a websocket transport expecting cross-process plugin communication. Typically arises when porting an Electron/web-based plugin setup to node without switching the transport.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/0f805c586d7edb3f. Report an issue: GitHub.