zed-industries/zed · error

failed to spawn threaded dispatcher timer

Error message

failed to spawn threaded dispatcher timer

What it means

ThreadedDispatcher::new fails to spawn its dedicated timer thread; the spawn error (resource exhaustion, thread limits) is unwrapped. Without the timer thread, dispatch_after timers would never fire, so startup fails loudly.

Source

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

                        // `run_until_idle` will wait for. Lock order is always
                        // timer state, then in-flight count; `run_until_idle`
                        // never takes them in the opposite order.
                        idle.increment();
                        drop(state);

                        {
                            let _decrement = idle.decrement_on_drop();
                            let location = entry.runnable.metadata().location;
                            let spawned = entry.runnable.metadata().spawned;
                            profiler::update_running_task(spawned, location);
                            entry.runnable.run();
                            profiler::save_task_timing();
                        }

                        state = timers.state.lock();
                    }
                })
                .expect("failed to spawn threaded dispatcher timer");
        }

        Self {
            background_sender,
            main_sender,
            main_receiver: Mutex::new(main_receiver),
            timers,
            idle,
            main_thread_id: thread::current().id(),
        }
    }

    /// Runs queued main thread tasks and waits until no background or timer
    /// work is queued, running, or already due.
    ///
    /// Timers that haven't reached their due time yet are *not* waited for:
    /// the dispatcher runs in real time and cannot skip ahead like the
    /// `TestDispatcher`'s virtual clock, so waiting on a future timer would

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Raise process/thread limits (ulimit -u, systemd TasksMax)
  2. Check for thread leaks elsewhere in the application that exhausted the limit
  3. Fall back to running timers on an existing worker thread
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui/src/platform/threaded_dispatcher.rs:198 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/6d09bd211737dc21. Report an issue: GitHub.