moeru-ai/airi · error · Error

WebSocket transport is not implemented for web runtime yet.

Error message

WebSocket transport is not implemented for web runtime yet.

What it means

Thrown by createPluginContext in the web runtime when transport.kind === 'websocket'. The browser host currently implements only the in-memory Eventa context; connecting a web extension session to a remote host over WebSocket is planned but unimplemented, so the request fails fast with an explicit message instead of half-working.

Solutions

  1. Use { kind: 'in-memory' } for the web runtime.
  2. Gate remote/websocket transport behind a capability check on the installed plugin-sdk version before selecting it.
  3. Upgrade plugin-sdk and confirm runtimes/web/index.ts implements the 'websocket' case before enabling.

Example fix

// before
const ctx = createPluginContext({ kind: 'websocket', url: 'wss://plugins.example.com' }) // web runtime: throws

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

Strategy: type-guard

Validate before calling

// Web runtime: only 'in-memory' is implemented.
if (transport.kind !== 'in-memory') {
  throw new Error(`Web plugin host supports only 'in-memory' transport, got '${transport.kind}'`)
}

Type guard

type WebSupportedTransport = Extract<PluginTransport, { kind: 'in-memory' }>
const isWebSupportedTransport = (t: PluginTransport): t is WebSupportedTransport => t.kind === 'in-memory'

Prevention

When it happens

Trigger: Bootstrapping a web plugin host with createPluginContext({ kind: 'websocket', url: 'ws://...' }) to reach a backend host; sharing transport config with a design that assumed remote browser plugins; enabling a 'remote plugins' feature flag before the implementation exists.

Common situations: Prototyping browser-side extension loading from a server; copying transport settings from architecture docs into code; feature flags turned on in a build whose plugin-sdk predates websocket support.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/43e833241d71253f. Report an issue: GitHub.

Appendix: source

Thrown at packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts:28

/**
 * Creates the Eventa context used by web-side extension host sessions.
 *
 * Use when:
 * - Bootstrapping a web runtime extension session
 *
 * Expects:
 * - `transport` describes a transport supported by the web runtime
 *
 * Returns:
 * - A web-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 web runtime yet.')
    case 'web-worker':
      throw new Error('Web worker transport is not implemented yet.')
    case 'node-worker':
      throw new Error('Node worker transport is not available in web runtime.')
    case 'electron':
      throw new Error('Electron transport is not available in web runtime.')
    default:
      throw new Error('Unknown plugin transport kind.')
  }
}

View on GitHub (pinned to 677329427f)