zed-industries/zed · error
Failed to initialize Tokio
Error message
Failed to initialize Tokio
What it means
gpui_tokio::init builds a multi-thread Tokio runtime and expects the runtime builder to succeed; failure means Tokio could not start its worker threads or I/O drivers (thread spawn/resource failure), so the Tokio bridge cannot be registered as a GPUI global.
Source
Thrown at crates/gpui_tokio/src/gpui_tokio.rs:18
use std::future::Future;
use gpui::{App, AppContext, Global, ReadGlobal, Task};
use gpui_util::defer;
pub use tokio::task::JoinError;
/// Initializes the Tokio wrapper using a new Tokio runtime with 2 worker threads.
///
/// If you need more threads (or access to the runtime outside of GPUI), you can create the runtime
/// yourself and pass a Handle to `init_from_handle`.
pub fn init(cx: &mut App) {
let runtime = tokio::runtime::Builder::new_multi_thread()
// Since we now have two executors, let's try to keep our footprint small
.worker_threads(2)
.enable_all()
.build()
.expect("Failed to initialize Tokio");
let handle = runtime.handle().clone();
cx.set_global(GlobalTokio {
owned_runtime: Some(runtime),
handle,
});
}
/// Initializes the Tokio wrapper using a Tokio runtime handle.
pub fn init_from_handle(cx: &mut App, handle: tokio::runtime::Handle) {
cx.set_global(GlobalTokio {
owned_runtime: None,
handle,
});
}
struct GlobalTokio {
owned_runtime: Option<tokio::runtime::Runtime>,View on GitHub (pinned to f4178619ac)
Solutions
- Check thread/fd limits that prevent Tokio worker or driver startup
- Verify init is called once; double init of the global would also be invalid
- Create the runtime yourself and use init_from_handle for custom configurations
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/gpui_tokio/src/gpui_tokio.rs:18 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/0b5f9199e2e70450.
Report an issue: GitHub.