{"record":{"id":"125cfe93b2bc6e31","repo":"tinyhumansai/openhuman","slug":"restart-core-is-only-available-in-the-desktop-app","errorCode":null,"errorMessage":"Restart Core is only available in the desktop app.","messagePattern":"Restart Core is only available in the desktop app\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"app/src/services/coreProcessControl.ts","lineNumber":18,"sourceCode":"/**\n * Thin wrapper around the Tauri `restart_core_process` IPC command.\n *\n * Surfaced via the Home blocking screen's \"Restart Core\" button (#1527) so\n * the user has a one-click recovery when the local sidecar has crashed or\n * is stuck. Outside Tauri (web preview / Vitest harness) this is a no-op\n * that returns a friendly error string.\n */\n// `safeInvoke` (in place of `@tauri-apps/api/core::invoke`) converts the CEF\n// `window.ipc.postMessage` synchronous throw — Sentry TAURI-REACT-7 /\n// TAURI-REACT-6 — into a rejected Promise so the caller's `await` /\n// `.catch(...)` can handle it instead of bubbling as an unhandled rejection.\nimport { safeInvoke as invoke, isTauri } from '../utils/tauriCommands/common';\nimport { clearCoreRpcTokenCache } from './coreRpcClient';\n\nexport async function restartCoreProcess(): Promise<void> {\n  if (!isTauri()) {\n    throw new Error('Restart Core is only available in the desktop app.');\n  }\n  await invoke('restart_core_process');\n  // The Tauri shell mints a fresh `OPENHUMAN_CORE_TOKEN` for the new core\n  // process. Drop the cached bearer so token-bearing long-lived consumers\n  // (e.g. webhook SSE, see #1922) reconnect with the new value.\n  clearCoreRpcTokenCache();\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/app/src/services/coreProcessControl.ts#L1-L26","documentation":"Thrown by restartCoreProcess() when isTauri() is false. Restarting the embedded core is a Tauri IPC command ('restart_core_process') on the desktop shell — in a web preview or the Vitest harness there is no core process and no IPC bridge, so the function refuses instead of calling a nonexistent command. The module deliberately uses safeInvoke, but this guard fires before any invoke attempt.","triggerScenarios":"Calling restartCoreProcess() from `pnpm dev` (Vite-only browser session), a web-only build, or a unit test without a Tauri mock; UI surfaces (settings buttons) reachable in non-Tauri contexts without an isTauri gate.","commonSituations":"Settings/troubleshooting screens tested in the browser dev server; Storybook or component tests rendering the restart button; e2e harnesses that load the UI outside the Tauri shell.","solutions":["Run inside the desktop shell (`pnpm dev:app` or the installed app) when you actually need to restart the core.","Gate the UI: hide/disable the Restart Core control when !isTauri().","In unit tests, mock '../utils/tauriCommands/common' so isTauri() returns true (or assert the throw explicitly for web behavior)."],"exampleFix":"// before\n<button onClick={() => restartCoreProcess()}>Restart Core</button>\n\n// after\n{isTauri()\n  ? <button onClick={() => restartCoreProcess()}>Restart Core</button>\n  : <span>Core restart is available in the desktop app.</span>}","handlingStrategy":"type-guard","validationCode":"import { isTauri } from '../utils/tauriCommands/common';\n\nconst canRestartCore = isTauri();\nif (!canRestartCore) {\n  // hide/disable the Restart Core control — calling it will throw in web contexts\n}","typeGuard":null,"tryCatchPattern":"try {\n  await restartCoreProcess();\n} catch (e) {\n  if (e instanceof Error && e.message === 'Restart Core is only available in the desktop app.') {\n    setNotice('Core restart requires the desktop app.');\n  } else throw e;\n}","preventionTips":["Gate restart controls on isTauri() at render time.","Use `pnpm dev:app` (not `pnpm dev`) when testing core lifecycle features.","Mock isTauri in Vitest when the code path under test calls restartCoreProcess."],"tags":["tauri","environment-check","core-process","desktop-only"],"backgroundTag":"platform-not-supported","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}