{"record":{"id":"248488cb633ca310","repo":"tracel-ai/burn","slug":"failed-to-install-signal-handler","errorCode":null,"errorMessage":"failed to install signal handler","messagePattern":"failed to install signal handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-communication/src/util.rs","lineNumber":12,"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}\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-communication/src/util.rs#L1-L25","documentation":"This panic fires when tokio's unix::signal(SignalKind::terminate()) fails to register a SIGTERM handler in os_shutdown_signal(). Failure means the tokio signal driver is unavailable in the current runtime. The library treats inability to observe termination signals as fatal since graceful shutdown could never complete.","triggerScenarios":"Calling start_iroh_async or start_websocket_async on Unix inside a runtime without the signal driver enabled; tokio::signal::unix::signal returns Err during os_shutdown_signal startup.","commonSituations":"Minimal tokio feature sets in embedded applications (e.g. no 'signal' feature), custom runtimes that skipped enable_all(), or platforms/configs where registering SIGTERM is disallowed.","solutions":["Build the tokio runtime with .enable_all() (or at minimum the signal driver) so SignalKind::terminate() registration succeeds.","Verify the tokio crate dependency includes the 'signal' feature.","Run the async start functions within a proper tokio::main / tokio::run context rather than a hand-rolled executor."],"exampleFix":"// before\ntokio::runtime::Builder::new_multi_thread().enable_io().build()?;\n// after\ntokio::runtime::Builder::new_multi_thread().enable_all().build()?;","handlingStrategy":"validation","validationCode":"#[cfg(unix)]\nassert!(tokio::runtime::Handle::try_current().is_ok(), \"SIGTERM handler needs a tokio runtime with the signal driver\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use .enable_all() when building the runtime","Include the 'signal' tokio feature on unix targets","Test shutdown paths in CI on a unix runner"],"tags":["rust","tokio","sigterm","unix","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"}