moeru-ai/airi · error · Error

Node worker transport is not available in web runtime.

Error message

Node worker transport is not available in web runtime.

What it means

Thrown by createPluginContext in the web runtime when transport.kind === 'node-worker'. Node worker_threads do not exist in browsers, so the web runtime permanently rejects this kind as unavailable (as opposed to the merely-unimplemented websocket/web-worker cases). It is a wrong-environment error: a Node-only transport reached the browser host.

Solutions

  1. Use { kind: 'in-memory' } in the web runtime; keep 'node-worker' for the Node host once implemented.
  2. Fix environment branching so browser bundles never select Node-only kinds.
  3. Validate the chosen kind against a per-runtime allowlist before calling createPluginContext.

Example fix

// before
const ctx = createPluginContext({ kind: 'node-worker' }) // web runtime: throws

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

Strategy: type-guard

Validate before calling

if (transport.kind === 'node-worker') {
  throw new Error('node-worker transport is Node-only; web host must use in-memory')
}

Type guard

const isNodeOnlyKind = (t: PluginTransport): boolean => t.kind === 'node-worker'
// in web bootstrap: if (isNodeOnlyKind(transport)) fail fast with your own message

Prevention

When it happens

Trigger: Passing { kind: 'node-worker' } to createPluginContext in browser code; environment-detection logic that picks the Node transport in the web bundle; config written for the Node host being imported by the web host.

Common situations: Shared transport-config modules used by both web and node entries; SSR/client bundles resolving the wrong branch; copy-pasted bootstrap between server and browser code.

Related errors


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

Appendix: source

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

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