{"record":{"id":"0ec037d68b28af63","repo":"zed-industries/zed","slug":"failed-to-spawn-threaded-dispatcher-realtime-threa","errorCode":null,"errorMessage":"failed to spawn threaded dispatcher realtime thread","messagePattern":"failed to spawn threaded dispatcher realtime thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/platform/threaded_dispatcher.rs","lineNumber":481,"sourceCode":"    fn dispatch_after(&self, duration: Duration, runnable: RunnableVariant) {\n        let mut state = self.timers.state.lock();\n        let seq = state.next_seq;\n        state.next_seq += 1;\n        state.heap.push(TimerEntry {\n            due: Instant::now() + duration,\n            seq,\n            runnable,\n        });\n        self.timers.condvar.notify_one();\n    }\n\n    fn spawn_realtime(&self, f: Box<dyn FnOnce() + Send>) {\n        // This dispatcher does not need realtime scheduling priority; a plain\n        // thread keeps it portable.\n        thread::Builder::new()\n            .name(\"ThreadedDispatcherRealtime\".to_owned())\n            .spawn(f)\n            .expect(\"failed to spawn threaded dispatcher realtime thread\");\n    }\n\n    fn as_threaded(&self) -> Option<&ThreadedDispatcher> {\n        Some(self)\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::future::Future;\n    use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};\n\n    use super::*;\n    use crate::{BackgroundExecutor, ForegroundExecutor};\n\n    #[test]\n    fn is_idle_tracks_queued_work_but_ignores_undue_timers() {\n        let dispatcher = Arc::new(ThreadedDispatcher::new());","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/platform/threaded_dispatcher.rs#L463-L499","documentation":"spawn_realtime creates a plain (non-realtime-priority) thread for immediate work; if the OS refuses the spawn the expect panics. This is thread-creation failure under resource pressure, not a scheduling problem.","triggerScenarios":"Thrown at crates/gpui/src/platform/threaded_dispatcher.rs:457 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check RLIMIT_NPROC and cgroup pids limits","Investigate thread leaks that consumed the thread budget","Consider queuing the closure onto an existing worker thread as a degraded mode"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}