{"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":"error","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/677329427f32468c74b17f3ec47eeca4e05bec65/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 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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use { kind: 'in-memory' } in the web runtime; keep 'node-worker' for the Node host once implemented.","Fix environment branching so browser bundles never select Node-only kinds.","Validate the chosen kind against a per-runtime allowlist before calling createPluginContext."],"exampleFix":"// before\nconst ctx = createPluginContext({ kind: 'node-worker' }) // web runtime: throws\n\n// after\nconst ctx = createPluginContext({ kind: 'in-memory' })","handlingStrategy":"type-guard","validationCode":"if (transport.kind === 'node-worker') {\n  throw new Error('node-worker transport is Node-only; web host must use in-memory')\n}","typeGuard":"const isNodeOnlyKind = (t: PluginTransport): boolean => t.kind === 'node-worker'\n// in web bootstrap: if (isNodeOnlyKind(transport)) fail fast with your own message","tryCatchPattern":null,"preventionTips":["Split transport config per runtime instead of sharing one object across bundles.","Add build-time checks that browser bundles never reference Node-only kinds."],"tags":["plugin-sdk","transport","node-worker","web-runtime","wrong-environment"],"backgroundTag":"unsupported-transport-kind","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}