{"record":{"id":"5a00f53db8015d1d","repo":"getzola/zola","slug":"could-not-build-tokio-runtime","errorCode":null,"errorMessage":"Could not build tokio runtime","messagePattern":"Could not build tokio runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/serve.rs","lineNumber":637,"sourceCode":"        }\n    }\n\n    let output_path = site.output_path.clone();\n    create_directory(&output_path)?;\n\n    // static_root needs to be canonicalized because we do the same for the http server.\n    let static_root = std::fs::canonicalize(&output_path).unwrap();\n\n    // Create broadcast channel for WebSocket live reload\n    let (reload_tx, _) = broadcast::channel::<String>(100);\n    let broadcaster = reload_tx.clone();\n\n    // Start Axum server in a separate thread\n    thread::spawn(move || {\n        let rt = tokio::runtime::Builder::new_current_thread()\n            .enable_all()\n            .build()\n            .expect(\"Could not build tokio runtime\");\n\n        rt.block_on(async {\n            let state = Arc::new(AppState { static_root, base_path, reload_tx });\n\n            let app = Router::new()\n                .route(\"/livereload.js\", get(serve_livereload_js))\n                .route(\"/livereload\", get(ws_handler))\n                .fallback(handle_request)\n                .layer(middleware::map_response(error_injection_middleware))\n                .with_state(state);\n\n            let listener = tokio::net::TcpListener::bind(&bind_address)\n                .await\n                .expect(\"Could not bind to address\");\n\n            let local_addr = listener.local_addr().unwrap();\n\n            log::info!(","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/cmd/serve.rs#L619-L655","documentation":"serve() spawns a dedicated thread that builds a single-threaded tokio runtime via tokio::runtime::Builder::new_current_thread().enable_all().build().expect(...). The expect fires when runtime construction fails, which is practically limited to cases like running inside an existing tokio runtime context, resource exhaustion, or an unsupported platform/backend — without a runtime the Axum server thread cannot run at all, so the process aborts that thread.","triggerScenarios":"Thrown at src/cmd/serve.rs:637 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the server thread is not spawned from within an async/tokio context that forbids nested runtimes","Check for resource limits (thread/memory) on the host if build() fails","Propagate the io::Error as a logged anyhow error instead of expect() so the failure reason is reported","Pin a known-good tokio version and verify platform support for the current-thread driver"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}