{"record":{"id":"1265623ebd555904","repo":"moeru-ai/airi","slug":"node-worker-transport-is-not-available-in-web-runt","errorCode":null,"errorMessage":"Node worker transport is not available in web runtime.","messagePattern":"Node worker transport is not available in web runtime\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts","lineNumber":32,"sourceCode":" * Use when:\n * - Bootstrapping a web runtime extension session\n *\n * Expects:\n * - `transport` describes a transport supported by the web runtime\n *\n * Returns:\n * - A web-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 web runtime yet.')\n    case 'web-worker':\n      throw new Error('Web worker transport is not implemented yet.')\n    case 'node-worker':\n      throw new Error('Node worker transport is not available in web runtime.')\n    case 'electron':\n      throw new Error('Electron transport is not available in web runtime.')\n    default:\n      throw new Error('Unknown plugin transport kind.')\n  }\n}\n","sourceCodeStart":14,"sourceCodeEnd":39,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts#L14-L39","documentation":"Thrown by `createPluginContext()` in the web runtime when `transport.kind === 'node-worker'`. Node Worker threads are not available in a browser environment, so the web runtime explicitly rejects this transport. This is a hard environment mismatch, not a missing feature.","triggerScenarios":"Selecting the `node-worker` transport kind while constructing a plugin context in the web runtime (browser bundle). Happens when Node-targeted plugin host config is loaded in a browser entrypoint.","commonSituations":"Sharing a plugin host configuration object across Node and web builds without conditioning the transport on environment; SSR or isomorphic code paths that accidentally execute the web runtime config server-style; build misconfiguration that ships the Node plugin host to the browser bundle.","solutions":["Use `createPluginContext({ kind: 'in-memory' })` in browser code; reserve `node-worker` for the Node runtime.","Condition transport selection on the detected runtime/environment rather than hardcoding it.","Audit build config (Vite entries, externalization) to ensure Node-only plugin host code is not bundled into the web target.","If you genuinely need Node Worker threads, run that plugin host in a Node process, not the web runtime."],"exampleFix":"// before\nconst ctx = createPluginContext({ kind: 'node-worker', workerPath })\n\n// after\nconst ctx = createPluginContext({ kind: 'in-memory' })","handlingStrategy":"type-guard","validationCode":"const runtime = detectRuntime()\nconst kind = runtime === 'node' ? 'node-worker' : 'in-memory'\nconst ctx = createPluginContext({ kind })","typeGuard":"function isBrowserRuntime(): boolean {\n  return typeof window !== 'undefined' && typeof (window as any).process === 'undefined'\n}\n\nfunction isWebSafeTransport(t: PluginTransport): boolean {\n  return t.kind === 'in-memory'\n}","tryCatchPattern":"try {\n  ctx = createPluginContext(transport)\n} catch (e) {\n  if (e instanceof Error && /not available in web runtime/i.test(e.message)) {\n    ctx = createPluginContext({ kind: 'in-memory' })\n  } else throw e\n}","preventionTips":["Never pass node-worker transport to the web runtime; reserve it for Node entrypoints.","Condition transport selection on runtime detection (browser vs node).","Audit Vite/externalization config so Node-only plugin host code stays out of the browser bundle.","Use environment-aware config objects instead of a single shared preset."],"tags":["plugin-sdk","web-runtime","transport","environment-mismatch"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}