{"record":{"id":"623474f9022d329d","repo":"tinyhumansai/openhuman","slug":"build-custom-tokio-runtime-for-tauri-async-surface","errorCode":null,"errorMessage":"build custom tokio runtime for tauri async surface","messagePattern":"build custom tokio runtime for tauri async surface","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src-tauri/src/lib.rs","lineNumber":2234,"sourceCode":"    // enough for that single tower, but sub-agent delegation (issue #3159\n    // / PR #3155) re-tipped the scale: the standalone `openhuman-core`\n    // CLI server still aborted with `Abort trap: 6 / fatal runtime error:\n    // stack overflow` once an orchestrator delegated. PR #3155 raised the\n    // standalone server to 16 MiB; the desktop Tauri host is the *same*\n    // tower running on a *different* runtime and needs the same headroom.\n    // Share the constant with the rest of `src/core/*` via\n    // [`openhuman_core::core::runtime::AGENT_WORKER_STACK_BYTES`] so all\n    // multi-thread runtimes that may host an agent turn stay in sync.\n    //\n    // Must happen before any `tauri::async_runtime::*` call, otherwise\n    // `set(...)` panics with \"runtime already initialized\".\n    {\n        let custom_runtime = tokio::runtime::Builder::new_multi_thread()\n            .enable_all()\n            .thread_stack_size(openhuman_core::core::runtime::AGENT_WORKER_STACK_BYTES)\n            .max_blocking_threads(openhuman_core::core::runtime::MAX_BLOCKING_THREADS)\n            .build()\n            .expect(\"build custom tokio runtime for tauri async surface\");\n        let handle = custom_runtime.handle().clone();\n        // Tauri docs: \"you cannot drop the underlying TokioRuntime.\"\n        // Leak it so its lifetime matches the process.\n        std::mem::forget(custom_runtime);\n        tauri::async_runtime::set(handle);\n    }\n\n    // Initialize Sentry for the Tauri shell (desktop host) process before any\n    // other startup work. Reads `OPENHUMAN_TAURI_SENTRY_DSN` at runtime first,\n    // then falls back to the value baked in at compile time via the release\n    // workflow. Missing/empty DSN ⇒ `sentry::init` returns a no-op guard.\n    //\n    // The guard is held for the entire lifetime of `run()` so events queued\n    // during shutdown still flush. Only invoked here (and not in `main.rs`)\n    // so renderer/GPU CEF helper subprocesses (re-exec'd via\n    // `tauri::cef_entry_point`) and the `OpenHuman core …` in-process core\n    // path do NOT spin up a second client — those have their own reporting\n    // surfaces.","sourceCodeStart":2216,"sourceCodeEnd":2252,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/app/src-tauri/src/lib.rs#L2216-L2252","documentation":"Panic payload on Runtime::new() in the desktop Tauri host: the shell builds a custom multi-thread tokio runtime (sized with AGENT_WORKER_STACK_BYTES, 16 MiB worker stacks) because sub-agent delegation overflows the default 2 MiB stack. This expect fires when the runtime itself cannot be constructed — almost always a resource-limit failure (rlimit on threads/resident memory) rather than a logic error.","triggerScenarios":"Thrown at app/src-tauri/src/lib.rs:2234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise OS thread/memory limits (ulimit -u, launchd plist) so tokio can spawn its worker pool","Check for another runtime already running in the same process (nested Runtime::new can fail)","Report the full panic backtrace alongside the core log if construction still fails"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}