{"record":{"id":"2b2482ffa6d4ca20","repo":"tokio-rs/tokio","slug":"the-worker-threads-option-requires-the-multi-th","errorCode":null,"errorMessage":"The `worker_threads` option requires the `multi_thread` runtime flavor. Use `#[{}(flavor = \"multi_thread\")]`","messagePattern":"The `worker_threads` option requires the `multi_thread` runtime flavor\\. Use `#\\[(.+?)\\(flavor = \"multi_thread\"\\)\\]`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"tokio-macros/src/entry.rs","lineNumber":200,"sourceCode":"    }\n\n    fn macro_name(&self) -> &'static str {\n        if self.is_test {\n            \"tokio::test\"\n        } else {\n            \"tokio::main\"\n        }\n    }\n\n    fn build(&self) -> Result<FinalConfig, syn::Error> {\n        use RuntimeFlavor as F;\n\n        let flavor = self.flavor.unwrap_or(self.default_flavor);\n\n        let worker_threads = match (flavor, self.worker_threads) {\n            (F::CurrentThread | F::Local, Some((_, worker_threads_span))) => {\n                let msg = format!(\n                    \"The `worker_threads` option requires the `multi_thread` runtime flavor. Use `#[{}(flavor = \\\"multi_thread\\\")]`\",\n                    self.macro_name(),\n                );\n                return Err(syn::Error::new(worker_threads_span, msg));\n            }\n            (F::CurrentThread | F::Local, None) => None,\n            (F::Threaded, worker_threads) if self.rt_multi_thread_available => {\n                worker_threads.map(|(val, _span)| val)\n            }\n            (F::Threaded, _) => {\n                let msg = if self.flavor.is_none() {\n                    \"The default runtime flavor is `multi_thread`, but the `rt-multi-thread` feature is disabled.\"\n                } else {\n                    \"The runtime flavor `multi_thread` requires the `rt-multi-thread` feature.\"\n                };\n                return Err(syn::Error::new(Span::call_site(), msg));\n            }\n        };\n","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio-macros/src/entry.rs#L182-L218","documentation":"In `build` (entry.rs:200), `worker_threads` is only meaningful for the `multi_thread` flavor. If the attribute combines `current_thread` or `local` flavor with `worker_threads = N`, the macro emits this guidance pointing the user at the required flavor change.","triggerScenarios":"Writing `#[tokio::main(flavor = \"current_thread\", worker_threads = 4)]` or `#[tokio::test(flavor = \"local\", worker_threads = 2)]`.","commonSituations":"Adding `worker_threads` while leaving the default/explicit single-threaded flavor; misunderstanding that `current_thread` ignores worker count.","solutions":["Switch the flavor to `multi_thread` if you actually want N worker threads: `#[tokio::main(flavor = \"multi_thread\", worker_threads = 4)]`.","Or remove the `worker_threads` option if the single-threaded runtime is intended.","Make sure the `rt-multi-thread` feature is enabled in `Cargo.toml` once you switch to `multi_thread`."],"exampleFix":"// before\n#[tokio::main(flavor = \"current_thread\", worker_threads = 4)]\nasync fn main() {}\n\n// after\n#[tokio::main(flavor = \"multi_thread\", worker_threads = 4)]\nasync fn main() {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["`worker_threads` requires `flavor = \"multi_thread\"`.","If you meant single-threaded, drop `worker_threads`.","Enable `rt-multi-thread` in `Cargo.toml` whenever you use the multi-thread flavor."],"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-14T05:17:10.506Z"}