{"record":{"id":"fd558329bd410264","repo":"tokio-rs/tokio","slug":"the-unhandled-panic-option-requires-the-current","errorCode":null,"errorMessage":"The `unhandled_panic` option requires the `current_thread` runtime flavor. Use `#[{}(flavor = \"current_thread\")]`","messagePattern":"The `unhandled_panic` option requires the `current_thread` runtime flavor\\. Use `#\\[(.+?)\\(flavor = \"current_thread\"\\)\\]`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"tokio-macros/src/entry.rs","lineNumber":234,"sourceCode":"            }\n        };\n\n        let start_paused = match (flavor, self.start_paused) {\n            (F::Threaded, Some((_, start_paused_span))) => {\n                let msg = format!(\n                    \"The `start_paused` option requires the `current_thread` runtime flavor. Use `#[{}(flavor = \\\"current_thread\\\")]`\",\n                    self.macro_name(),\n                );\n                return Err(syn::Error::new(start_paused_span, msg));\n            }\n            (F::CurrentThread | F::Local, Some((start_paused, _))) => Some(start_paused),\n            (_, None) => None,\n        };\n\n        let unhandled_panic = match (flavor, self.unhandled_panic) {\n            (F::Threaded, Some((_, unhandled_panic_span))) => {\n                let msg = format!(\n                    \"The `unhandled_panic` option requires the `current_thread` runtime flavor. Use `#[{}(flavor = \\\"current_thread\\\")]`\",\n                    self.macro_name(),\n                );\n                return Err(syn::Error::new(unhandled_panic_span, msg));\n            }\n            (F::CurrentThread | F::Local, Some((unhandled_panic, _))) => Some(unhandled_panic),\n            (_, None) => None,\n        };\n\n        Ok(FinalConfig {\n            name: self.name.clone(),\n            crate_name: self.crate_name.clone(),\n            flavor,\n            worker_threads,\n            start_paused,\n            unhandled_panic,\n        })\n    }\n}","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio-macros/src/entry.rs#L216-L252","documentation":"In `build` (entry.rs:233), `unhandled_panic` policy is only honored by the `current_thread` runtime. Setting it together with `flavor = \"multi_thread\"` is rejected and the user is pointed to `current_thread`.","triggerScenarios":"Writing `#[tokio::main(flavor = \"multi_thread\", unhandled_panic = \"shutdown_runtime\")]`.","commonSituations":"Wanting panic-shutdown semantics but defaulting to the multi-thread flavor; copying a panic-policy from a single-threaded example into a multi-thread entry point.","solutions":["Switch the flavor to `current_thread`: `#[tokio::main(flavor = \"current_thread\", unhandled_panic = \"shutdown_runtime\")]`.","Or remove `unhandled_panic` and handle task panics via `JoinHandle::is_panicked` / supervision instead."],"exampleFix":"// before\n#[tokio::main(flavor = \"multi_thread\", unhandled_panic = \"shutdown_runtime\")]\nasync fn main() {}\n\n// after\n#[tokio::main(flavor = \"current_thread\", unhandled_panic = \"shutdown_runtime\")]\nasync fn main() {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["`unhandled_panic` requires `flavor = \"current_thread\"`.","If you need panic supervision on the multi-thread runtime, supervise via `JoinHandle` instead.","Keep the flavor and the panic-policy option consistent."],"tags":["tokio","macros","compile-error","config","flavor-mismatch"],"backgroundTag":null,"analyzedSha":"625954f365727668cb02d04172b34f1149637728","analyzedAt":"2026-08-11T17:46:45.378Z","contentChangedAt":"2026-08-11T17:46:45.378Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}