moeru-ai/airi · error · Error

Web worker transport is not available in node runtime.

Error message

Web worker transport is not available in node runtime.

What it means

Thrown by createPluginContext in the node runtime when transport.kind === 'web-worker'. Unlike the 'not implemented yet' cases, this is a permanent availability rule: Web Workers are a browser API and cannot exist in Node, so the node runtime rejects the kind outright rather than treating it as pending work.

Solutions

  1. Use { kind: 'in-memory' } in Node; keep 'web-worker' only for the web runtime host.
  2. Fix environment-based transport selection so Node never resolves to a browser-only kind.
  3. Assert the resolved transport against a per-runtime allowlist before calling createPluginContext so mistakes surface in your own error message.

Example fix

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

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

Strategy: type-guard

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: Passing { kind: 'web-worker' } to createPluginContext in a Node process; isomorphic code that picks web-worker when typeof window !== 'undefined' logic is inverted; config written for the web host being reused by a Node host.

Common situations: Sharing transport config between web and node entrypoints; environment detection bugs that select the browser transport server-side; copy-pasted bootstrap from a web plugin host into a Node script or test.

Related errors


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

Appendix: source

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

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