{"record":{"id":"39d4af82a51455ba","repo":"tracel-ai/burn","slug":"failed-to-build-the-tokio-runtime","errorCode":null,"errorMessage":"Failed to build the tokio runtime","messagePattern":"Failed to build the tokio runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-remote/src/server/builder.rs","lineNumber":160,"sourceCode":"                )\n                .await;\n            }\n            #[cfg(feature = \"iroh\")]\n            Channel::Iroh { secret } => {\n                crate::transport::iroh::server::start_iroh_async::<B>(\n                    *secret,\n                    self.devices,\n                    self.custom_ops,\n                )\n                .await;\n            }\n        }\n    }\n\n    /// Start the server, blocking the current thread until shutdown.\n    #[cfg(not(target_family = \"wasm\"))]\n    pub fn start(self) {\n        let runtime = tokio::runtime::Runtime::new().expect(\"Failed to build the tokio runtime\");\n        runtime.block_on(self.start_async());\n    }\n}\n","sourceCodeStart":142,"sourceCodeEnd":164,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-remote/src/server/builder.rs#L142-L164","documentation":"The server's blocking start() creates a fresh multi-threaded tokio runtime via Runtime::new() and panics if construction fails. This indicates the process cannot create the async runtime (resource limits, platform constraints).","triggerScenarios":"Calling ServerBuilder::start() on non-wasm targets when tokio cannot build a runtime — e.g. insufficient memory, exhausted thread limits, or calling within an existing runtime context that forbids blocking.","commonSituations":"Embedding the blocking server start inside another tokio runtime thread; containers with very low thread/memory limits; exotic platforms lacking required primitives.","solutions":["Don't call blocking start() inside an async context — use start_async() and await it from your own runtime","Check ulimits/rlimits (nproc) and container memory limits","Ensure the tokio crate is compiled with the features needed to build a runtime","Run the server on a dedicated OS thread: std::thread::spawn(move || server.start())"],"exampleFix":"// before\nserver.start(); // inside async fn — panics/blocks\n// after\n#[cfg(not(target_family = \"wasm\"))]\nstd::thread::spawn(move || server.start());","handlingStrategy":"fallback","validationCode":"// Only call blocking start() outside any async runtime:\nassert!(tokio::runtime::Handle::try_current().is_err(),\n    \"use start_async() inside an existing runtime\");","typeGuard":null,"tryCatchPattern":"std::thread::spawn(move || server.start())\n    .join()\n    .map_err(|_| anyhow!(\"remote server thread panicked building the tokio runtime\"))?;","preventionTips":["Call start_async() from your own tokio runtime instead of blocking start() inside async code","Verify container/ulimit resources allow creating a tokio runtime","Run the server on a dedicated thread when embedding"],"tags":["rust","tokio","runtime","server"],"backgroundTag":"tokio-runtime-build-failed","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}