{"record":{"id":"2afd6c37a9f60029","repo":"elkowar/eww","slug":"failed-to-start-script-var-handler-thread","errorCode":null,"errorMessage":"Failed to start script-var-handler thread","messagePattern":"Failed to start script-var-handler thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/script_var_handler.rs","lineNumber":61,"sourceCode":"                            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                            }\n                        },\n                        else => break,\n                    };\n                    Ok(())\n                }\n                .await;\n            })\n        })\n        .expect(\"Failed to start script-var-handler thread\");\n    ScriptVarHandlerHandle { msg_send, thread_handle }\n}\n\n/// Handle to the script-var handling system.\npub struct ScriptVarHandlerHandle {\n    msg_send: UnboundedSender<ScriptVarHandlerMsg>,\n    thread_handle: std::thread::JoinHandle<()>,\n}\n\nimpl ScriptVarHandlerHandle {\n    /// Add a new script-var that should be executed.\n    /// This is idempodent, meaning that running a definition that already has a script_var attached which is running\n    /// won't do anything.\n    pub fn add(&self, script_var: ScriptVarDefinition) {\n        crate::print_result_err!(\n            \"while forwarding instruction to script-var handler\",\n            self.msg_send.send(ScriptVarHandlerMsg::AddVar(script_var))\n        );","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/script_var_handler.rs#L43-L79","documentation":"`ScriptVarHandler::init` spawns the OS thread that hosts the handler runtime. If `std::thread::Builder::spawn` fails, the `expect` panics with this message. Without the thread, script variables (poll/listen) will not be evaluated, so eww aborts rather than run with a broken var system.","triggerScenarios":"`ScriptVarHandler::init` when the OS refuses to spawn the \"outer-script-var-handler\" thread (resource exhaustion, thread limits, security restrictions).","commonSituations":"Hitting `ulimit -u` thread limits, running in restricted sandboxes/containers denying thread creation, low-memory conditions.","solutions":["Raise thread limits: `ulimit -u unlimited` (or a higher value) for the eww process.","Check sandbox/container policies that block thread creation and allow them.","Free system resources / investigate memory pressure that prevents spawning threads."],"exampleFix":"// before (systemd unit)\nTasksMax=30\n// after\nTasksMax=infinity","handlingStrategy":"retry","validationCode":"let ok = std::thread::available_parallelism().is_ok(); // thread env sanity check (approximate)","typeGuard":null,"tryCatchPattern":"match std::thread::Builder::new().name(\"outer-script-var-handler\".into()).spawn(work) {\n    Ok(h) => h,\n    Err(e) => { eprintln!(\"handler thread spawn failed: {e}\"); return ...; }\n}","preventionTips":["Raise `ulimit -u` / systemd TasksMax for user services running eww.","Avoid heavy thread consumers co-resident with eww in constrained containers.","Monitor memory pressure that can make thread creation fail."],"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"}