{"record":{"id":"7c4bb0ad70068f41","repo":"tokio-rs/tokio","slug":"worker-threads-set-multiple-times","errorCode":null,"errorMessage":"`worker_threads` set multiple times.","messagePattern":"`worker_threads` set multiple times\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"tokio-macros/src/entry.rs","lineNumber":134,"sourceCode":"            return Err(syn::Error::new(span, \"`flavor` set multiple times.\"));\n        }\n\n        let runtime_str = parse_string(runtime, span, \"flavor\")?;\n        let runtime =\n            RuntimeFlavor::from_str(&runtime_str).map_err(|err| syn::Error::new(span, err))?;\n        self.flavor = Some(runtime);\n        Ok(())\n    }\n\n    fn set_worker_threads(\n        &mut self,\n        worker_threads: syn::Lit,\n        span: Span,\n    ) -> Result<(), syn::Error> {\n        if self.worker_threads.is_some() {\n            return Err(syn::Error::new(\n                span,\n                \"`worker_threads` set multiple times.\",\n            ));\n        }\n\n        let worker_threads = parse_int(worker_threads, span, \"worker_threads\")?;\n        if worker_threads == 0 {\n            return Err(syn::Error::new(span, \"`worker_threads` may not be 0.\"));\n        }\n        self.worker_threads = Some((worker_threads, span));\n        Ok(())\n    }\n\n    fn set_start_paused(&mut self, start_paused: syn::Lit, span: Span) -> Result<(), syn::Error> {\n        if self.start_paused.is_some() {\n            return Err(syn::Error::new(span, \"`start_paused` set multiple times.\"));\n        }\n\n        let start_paused = parse_bool(start_paused, span, \"start_paused\")?;\n        self.start_paused = Some((start_paused, span));","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio-macros/src/entry.rs#L116-L152","documentation":"`set_worker_threads` (entry.rs:130) records the first `worker_threads = N` and rejects any second occurrence in the same attribute. `worker_threads` is meaningful only for the `multi_thread` flavor, but the duplicate check runs at parse time regardless.","triggerScenarios":"Writing `#[tokio::main(worker_threads = 2, worker_threads = 4)]`.","commonSituations":"Conditionally-edited attributes where an old value was left in place; copy-paste.","solutions":["Remove the duplicate `worker_threads` so a single value remains.","Pick one worker count and delete the other."],"exampleFix":"// before\n#[tokio::main(flavor = \"multi_thread\", worker_threads = 2, 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":["Set `worker_threads` at most once per attribute.","Only set it when `flavor = \"multi_thread\"`.","Prefer letting tokio pick the default unless you have a specific reason."],"tags":["tokio","macros","compile-error","config","duplicate-option"],"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"}