{"record":{"id":"15d4fd0094169623","repo":"tracel-ai/burn","slug":"failed-to-install-ctrl-c-handler","errorCode":null,"errorMessage":"failed to install Ctrl+C handler","messagePattern":"failed to install Ctrl\\+C handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-communication/src/util.rs","lineNumber":6,"sourceCode":"/// Utilities to help handle communication termination.\npub async fn os_shutdown_signal() {\n    let ctrl_c = async {\n        tokio::signal::ctrl_c()\n            .await\n            .expect(\"failed to install Ctrl+C handler\");\n    };\n\n    #[cfg(unix)]\n    let terminate = async {\n        tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())\n            .expect(\"failed to install signal handler\")\n            .recv()\n            .await;\n    };\n\n    #[cfg(not(unix))]\n    let terminate = std::future::pending::<()>();\n\n    tokio::select! {\n        _ = ctrl_c => {},\n        _ = terminate => {},\n    }\n}","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-communication/src/util.rs#L1-L24","documentation":"This panic comes from tokio's ctrl_c() inside os_shutdown_signal(), which installs a SIGINT handler for graceful shutdown. Installation can only fail if the tokio runtime has no signal driver (e.g. called via block_on with runtime disabled or io/signal driver not enabled). The library panics because shutdown signaling is considered essential and unrecoverable.","triggerScenarios":"Calling start_iroh_async or start_websocket_async inside a runtime built without the signal feature, or on a runtime lacking signal handling support; tokio::signal::ctrl_c() returns Err before awaiting the signal.","commonSituations":"Embedding burn's communication server in a custom tokio runtime with feature flags stripped (no 'signal' support), using a current-thread runtime assembled manually, or running under an environment that forbids signal handler installation.","solutions":["Enable tokio features 'signal' (and 'io-util'/'rt-multi-thread' as needed) in Cargo.toml and build the runtime with the default builder so the signal driver is registered.","Ensure os_shutdown_signal is awaited inside a tokio runtime context, not on a bare std thread.","If signal handling must be optional, replace the expect with graceful error propagation in a forked copy of util.rs."],"exampleFix":"// before (custom runtime without signal driver)\nlet rt = tokio::runtime::Builder::new_current_thread().enable_io().build()?;\n// after\nlet rt = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;\n// and in Cargo.toml: tokio = { version = \"1\", features = [\"full\"] }","handlingStrategy":"validation","validationCode":"// Ensure a full-featured tokio runtime wraps the call\nassert!(tokio::runtime::Handle::try_current().is_ok(), \"must run inside a tokio runtime\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable tokio's 'signal' feature and .enable_all() on the runtime","Only call start_iroh_async/start_websocket_async from within a tokio runtime","Pin the tokio version and features in Cargo.toml (features = [\"full\"] for apps)"],"tags":["rust","tokio","signal-handling","panic"],"backgroundTag":"signal-handler-install-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"}