{"record":{"id":"0b5f9199e2e70450","repo":"zed-industries/zed","slug":"failed-to-initialize-tokio","errorCode":null,"errorMessage":"Failed to initialize Tokio","messagePattern":"Failed to initialize Tokio","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_tokio/src/gpui_tokio.rs","lineNumber":18,"sourceCode":"use std::future::Future;\n\nuse gpui::{App, AppContext, Global, ReadGlobal, Task};\nuse gpui_util::defer;\n\npub use tokio::task::JoinError;\n\n/// Initializes the Tokio wrapper using a new Tokio runtime with 2 worker threads.\n///\n/// If you need more threads (or access to the runtime outside of GPUI), you can create the runtime\n/// yourself and pass a Handle to `init_from_handle`.\npub fn init(cx: &mut App) {\n    let runtime = tokio::runtime::Builder::new_multi_thread()\n        // Since we now have two executors, let's try to keep our footprint small\n        .worker_threads(2)\n        .enable_all()\n        .build()\n        .expect(\"Failed to initialize Tokio\");\n\n    let handle = runtime.handle().clone();\n    cx.set_global(GlobalTokio {\n        owned_runtime: Some(runtime),\n        handle,\n    });\n}\n\n/// Initializes the Tokio wrapper using a Tokio runtime handle.\npub fn init_from_handle(cx: &mut App, handle: tokio::runtime::Handle) {\n    cx.set_global(GlobalTokio {\n        owned_runtime: None,\n        handle,\n    });\n}\n\nstruct GlobalTokio {\n    owned_runtime: Option<tokio::runtime::Runtime>,","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_tokio/src/gpui_tokio.rs#L1-L36","documentation":"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.","triggerScenarios":"Thrown at crates/gpui_tokio/src/gpui_tokio.rs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}