moeru-ai/airi · error · Error

Electron transport is not available in web runtime.

Error message

Electron transport is not available in web runtime.

What it means

Thrown by createPluginContext in the web runtime when transport.kind === 'electron'. Electron IPC transport requires the Electron runtime's main/renderer bridges; in a plain browser those APIs do not exist, so the web runtime rejects the kind permanently. Reaching this throw means web code is reusing Electron-oriented transport configuration.

Solutions

  1. Use { kind: 'in-memory' } for the web host; reserve 'electron' for the Electron runtime host.
  2. Branch by platform when building the transport (e.g. check for the Electron preload bridge) instead of one shared constant.
  3. Fail fast on invalid combos in your own config validation so this never surfaces at runtime.

Example fix

// before
const ctx = createPluginContext({ kind: 'electron' }) // browser: throws

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

Strategy: type-guard

Validate before calling

// Pick electron transport only inside the Electron renderer/preload:
const isElectronRuntime = typeof navigator !== 'undefined' && navigator.userAgent.includes('Electron')
const transport = isElectronRuntime ? { kind: 'electron' } : { kind: 'in-memory' }

Type guard

const isElectronRenderer = (): boolean =>
  typeof navigator !== 'undefined' && navigator.userAgent.includes('Electron')
// web host: if (!isElectronRenderer()) require transport.kind === 'in-memory'

Prevention

When it happens

Trigger: Importing the web runtime's createPluginContext with { kind: 'electron' } inherited from desktop config; isomorphic module evaluated in the browser hitting the electron branch; a shared default transport constant used by both Electron and web entries.

Common situations: Monorepo shared bootstrap between stage-tamagotchi (Electron) and stage-web; defaults defined in a common package; testing web builds with desktop env vars present.

Related errors


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

Appendix: source

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

 *
 * 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)