zed-industries/zed · error

failed to spawn threaded dispatcher realtime thread

Error message

failed to spawn threaded dispatcher realtime thread

What it means

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.

Source

Thrown at crates/gpui/src/platform/threaded_dispatcher.rs:481

    fn dispatch_after(&self, duration: Duration, runnable: RunnableVariant) {
        let mut state = self.timers.state.lock();
        let seq = state.next_seq;
        state.next_seq += 1;
        state.heap.push(TimerEntry {
            due: Instant::now() + duration,
            seq,
            runnable,
        });
        self.timers.condvar.notify_one();
    }

    fn spawn_realtime(&self, f: Box<dyn FnOnce() + Send>) {
        // This dispatcher does not need realtime scheduling priority; a plain
        // thread keeps it portable.
        thread::Builder::new()
            .name("ThreadedDispatcherRealtime".to_owned())
            .spawn(f)
            .expect("failed to spawn threaded dispatcher realtime thread");
    }

    fn as_threaded(&self) -> Option<&ThreadedDispatcher> {
        Some(self)
    }
}

#[cfg(test)]
mod tests {
    use std::future::Future;
    use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};

    use super::*;
    use crate::{BackgroundExecutor, ForegroundExecutor};

    #[test]
    fn is_idle_tracks_queued_work_but_ignores_undue_timers() {
        let dispatcher = Arc::new(ThreadedDispatcher::new());

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Check RLIMIT_NPROC and cgroup pids limits
  2. Investigate thread leaks that consumed the thread budget
  3. Consider queuing the closure onto an existing worker thread as a degraded mode
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui/src/platform/threaded_dispatcher.rs:457 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/0ec037d68b28af63. Report an issue: GitHub.