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 adapter when transport.kind is 'web-worker'. Web workers are a browser/DOM concept and are fundamentally unavailable in node, so this guard distinguishes a hard environment mismatch from a not-yet-implemented feature.
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 27111382b4)
Solutions
- Use a node-compatible transport ({ kind: 'in-memory' } or node-worker once implemented) when running in node.
- Branch transport selection on the runtime/environment so node never receives a web-worker transport.
- If browser worker isolation is needed, run the host in a browser/web-runtime adapter instead of node.
Example fix
// before
const ctx = createPluginContext({ kind: 'web-worker', worker: new Worker('./plugin.js') })
// after
const ctx = createPluginContext({ kind: 'in-memory' }) Defensive patterns
Strategy: validation
Validate before calling
if (transport.kind === 'web-worker') {
throw new Error('web-worker transport is unavailable in node. Use in-memory.')
}
const ctx = createPluginContext(transport) Type guard
function isNodeCompatibleTransport(transport: PluginTransport): boolean {
return transport.kind === 'in-memory'
} Try / catch
try {
ctx = createPluginContext(transport)
} catch (error) {
if (error instanceof Error && /Web worker transport is not available in node/.test(error.message)) {
ctx = createPluginContext({ kind: 'in-memory' })
} else {
throw error
}
} Prevention
- Never pass browser-only transports (web-worker) to a node host.
- Branch transport selection on environment (isNode ? in-memory : web-worker).
- Keep shared transport config conditioned on the active runtime.
When it happens
Trigger: Calling createPluginContext({ kind: 'web-worker', worker }) where worker is a browser Worker instance, from a node process. This is an environment error, not a missing feature.
Common situations: Sharing transport configuration between a web app and a node server without conditioning on environment. Or a library default that assumes browser globals leaking into a node host.
Related errors
- WebSocket transport is not implemented for node runtime yet.
- Node worker transport is not implemented yet.
- Electron transport is not implemented yet.
- Unknown plugin transport kind.
- Web worker transport is not implemented yet.
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/8350d1770b7c2109.
Report an issue: GitHub.