{"record":{"id":"d693e07315083597","repo":"elkowar/eww","slug":"failed-to-initialize-tokio-runtime-for-script-var","errorCode":null,"errorMessage":"Failed to initialize tokio runtime for script var handlers","messagePattern":"Failed to initialize tokio runtime for script var handlers","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/script_var_handler.rs","lineNumber":34,"sourceCode":"use tokio::{\n    io::{AsyncBufReadExt, BufReader},\n    sync::mpsc::UnboundedSender,\n};\nuse tokio_util::sync::CancellationToken;\nuse yuck::config::script_var_definition::{ListenScriptVar, PollScriptVar, ScriptVarDefinition, VarSource};\n\n/// Initialize the script var handler, and return a handle to that handler, which can be used to control\n/// the script var execution.\npub fn init(evt_send: UnboundedSender<DaemonCommand>) -> ScriptVarHandlerHandle {\n    let (msg_send, mut msg_recv) = tokio::sync::mpsc::unbounded_channel();\n    let thread_handle = std::thread::Builder::new()\n        .name(\"outer-script-var-handler\".to_string())\n        .spawn(move || {\n            let rt = tokio::runtime::Builder::new_multi_thread()\n                .enable_all()\n                .thread_name(\"script-var-handler\")\n                .build()\n                .expect(\"Failed to initialize tokio runtime for script var handlers\");\n            rt.block_on(async {\n                let _: Result<_> = async {\n                    let mut handler = ScriptVarHandler {\n                        listen_handler: ListenVarHandler::new(evt_send.clone())?,\n                        poll_handler: PollVarHandler::new(evt_send)?,\n                    };\n                    crate::loop_select_exiting! {\n                        Some(msg) = msg_recv.recv() => match msg {\n                            ScriptVarHandlerMsg::AddVar(var) => {\n                                handler.add(var).await;\n                            }\n                            ScriptVarHandlerMsg::Stop(name) => {\n                                handler.stop_for_variable(&name).await?;\n                            }\n                            ScriptVarHandlerMsg::StopAll => {\n                                handler.stop_all().await;\n                                break;\n                            }","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/script_var_handler.rs#L16-L52","documentation":"The script-var handler spawns a background thread that builds a multi-thread tokio runtime; if runtime construction fails, the `expect` panics inside that thread with this message. Without this runtime, poll and listen script vars cannot be processed.","triggerScenarios":"Calling `ScriptVarHandler::init` when `Builder::new_multi_thread().enable_all().build()` returns an Err on the spawned thread.","commonSituations":"Tokio compiled without multi-thread scheduler or driver features; systems where thread/worker creation is restricted (ulimit, containers).","solutions":["Enable the required tokio features in Cargo.toml (`features = [\"full\"]` or at least `rt-multi-thread`, `macros`, `time`, `process`).","Raise thread/process limits (ulimit -u) or relax container restrictions if worker-thread spawning fails.","Check platform support for the multi-thread runtime."],"exampleFix":"// Cargo.toml before\ntokio = { version = \"1\", features = [\"rt\"] }\n// after\ntokio = { version = \"1\", features = [\"rt-multi-thread\", \"macros\", \"time\", \"process\"] }","handlingStrategy":"try-catch","validationCode":"// compile-time: tokio = { features = [\"rt-multi-thread\", \"macros\", \"time\", \"process\"] }","typeGuard":null,"tryCatchPattern":"let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build();\nif let Err(e) = rt { eprintln!(\"script-var handler disabled: {e}\"); return; }","preventionTips":["Require rt-multi-thread and driver features for tokio.","Watch thread limits (ulimit -u) in the deployment environment.","Avoid building multi-thread runtimes on unsupported platforms."],"tags":[],"backgroundTag":null,"analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}