{"record":{"id":"ced3c7e82156668d","repo":"moeru-ai/airi","slug":"electron-transport-is-not-available-in-web-runtime","errorCode":null,"errorMessage":"Electron transport is not available in web runtime.","messagePattern":"Electron 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":34,"sourceCode":" *\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":16,"sourceCodeEnd":39,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts#L16-L39","documentation":"Thrown by `createPluginContext()` in the web runtime when `transport.kind === 'electron'`. Electron IPC transports require the Electron renderer bridge (`window.electron`), which does not exist in a plain web context, so the web runtime rejects it. This is an environment mismatch guard.","triggerScenarios":"Selecting the `electron` transport kind in a non-Electron web context. Occurs when Electron-targeted plugin host configuration is loaded in a regular browser build or when the Electron preload bridge is unavailable.","commonSituations":"Sharing plugin host config between the Electron (stage-tamagotchi) and web (stage-web) apps without conditioning on runtime; running the web app outside Electron while config still defaults to the electron transport; preload script not injected so the bridge is missing.","solutions":["Use `createPluginContext({ kind: 'in-memory' })` for the web runtime; keep `electron` transport for the stage-tamagotchi renderer only.","Detect the runtime (e.g. check for the Electron preload bridge) before selecting a transport kind.","Verify the Electron preload bridge is injected before selecting the electron transport in renderer code.","Audit shared config so transport selection is environment-aware."],"exampleFix":"// before\nconst ctx = createPluginContext({ kind: 'electron' })\n\n// after\nconst ctx = createPluginContext({ kind: 'in-memory' })","handlingStrategy":"type-guard","validationCode":"const isElectron = typeof window !== 'undefined' && !!(window as any).electron\nconst kind = isElectron ? 'electron' : 'in-memory'\nconst ctx = createPluginContext({ kind })","typeGuard":"function hasElectronBridge(w: Window & typeof globalThis): boolean {\n  return Boolean((w as unknown as { electron?: unknown }).electron)\n}\n\nfunction isWebSafeTransport(t: PluginTransport): boolean {\n  return t.kind !== 'electron'\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":["Select the electron transport only inside the Electron renderer with a confirmed preload bridge.","Detect the bridge (window.electron) before choosing a transport kind.","Keep Electron-specific plugin host config out of the web app bundle.","Make shared config environment-aware."],"tags":["plugin-sdk","web-runtime","transport","electron","environment-mismatch"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}