{"record":{"id":"8350d1770b7c2109","repo":"moeru-ai/airi","slug":"web-worker-transport-is-not-available-in-node-runt","errorCode":null,"errorMessage":"Web worker transport is not available in node runtime.","messagePattern":"Web worker transport is not available in node runtime\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-sdk/src/plugin-host/runtimes/node/index.ts","lineNumber":35,"sourceCode":" *\n * Expects:\n * - `transport` describes a transport supported by the node runtime\n *\n * Returns:\n * - A node-compatible Eventa context, or throws if the transport is not implemented\n */\nexport function createPluginContext(transport: PluginTransport): EventContext<any, any> {\n  switch (transport.kind) {\n    case 'in-memory':\n      return createContext()\n    case 'websocket':\n      throw new Error('WebSocket transport is not implemented for node runtime yet.')\n    case 'node-worker':\n      throw new Error('Node worker transport is not implemented yet.')\n    case 'electron':\n      throw new Error('Electron transport is not implemented yet.')\n    case 'web-worker':\n      throw new Error('Web worker transport is not available in node runtime.')\n    default:\n      throw new Error('Unknown plugin transport kind.')\n  }\n}\n","sourceCodeStart":17,"sourceCodeEnd":40,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/plugin-sdk/src/plugin-host/runtimes/node/index.ts#L17-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst ctx = createPluginContext({ kind: 'web-worker', worker: new Worker('./plugin.js') })\n\n// after\nconst ctx = createPluginContext({ kind: 'in-memory' })","handlingStrategy":"validation","validationCode":"if (transport.kind === 'web-worker') {\n  throw new Error('web-worker transport is unavailable in node. Use in-memory.')\n}\nconst ctx = createPluginContext(transport)","typeGuard":"function isNodeCompatibleTransport(transport: PluginTransport): boolean {\n  return transport.kind === 'in-memory'\n}","tryCatchPattern":"try {\n  ctx = createPluginContext(transport)\n} catch (error) {\n  if (error instanceof Error && /Web worker transport is not available in node/.test(error.message)) {\n    ctx = createPluginContext({ kind: 'in-memory' })\n  } else {\n    throw error\n  }\n}","preventionTips":["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."],"tags":["transport","node","web-worker","environment-mismatch"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}