zed-industries/zed · error

failed to spawn dedicated thread

Error message

failed to spawn dedicated thread

What it means

Raised in spawn_dedicated_os_thread(): std::thread::Builder::spawn for the dedicated scheduler thread failed (thread creation error, e.g. resource limits), so the dedicated executor session cannot start.

Solutions

  1. Reduce concurrent thread usage in the process
  2. Check ulimit -u / pthread limits on the host
  3. Retry after load subsides or fall back to a shared thread pool
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/scheduler/src/scheduler.rs:212 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/293472c391cbe859. Report an issue: GitHub.

Appendix: source

Thrown at crates/scheduler/src/scheduler.rs:212

        // lives inside a spawned task or a user-held executor clone. The
        // recv loop exits once all of those are gone.
        drop(executor);

        while let Ok(runnable) = runnable_receiver.recv() {
            runnable.run();
        }
    };
    spawn_dedicated_os_thread(session_id, thread_body);
    task
}

fn spawn_dedicated_os_thread(session_id: SessionId, thread_body: impl FnOnce() + Send + 'static) {
    let thread_name = format!("spawn_dedicated session {:?}", session_id);
    #[cfg(not(target_family = "wasm"))]
    std::thread::Builder::new()
        .name(thread_name)
        .spawn(thread_body)
        .expect("failed to spawn dedicated thread");
    #[cfg(all(target_family = "wasm", feature = "wasm-threads"))]
    wasm_thread::Builder::new()
        .name(thread_name)
        .spawn(thread_body)
        .expect("failed to spawn dedicated thread");
    #[cfg(all(target_family = "wasm", not(feature = "wasm-threads")))]
    {
        let _ = (thread_name, thread_body);
        panic!("spawn_dedicated on wasm requires the scheduler crate's `wasm-threads` feature");
    }
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct SessionId(u16);

impl SessionId {
    pub fn new(id: u16) -> Self {
        SessionId(id)

View on GitHub (pinned to f4178619ac)