{"record":{"id":"4fd96d1e82c4685d","repo":"facebook/flow","slug":"workers-required-for-init","errorCode":null,"errorMessage":"workers required for init","messagePattern":"workers required for init","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_codemods/src/utils/codemod_runner.rs","lineNumber":1197,"sourceCode":"                    }\n                    flow_services_inference::merge_service::CheckJobOutcome::PerFileError(e) => {\n                        acc.insert(file, Err(e));\n                    }\n                    flow_services_inference::merge_service::CheckJobOutcome::Canceled(c) => {\n                        return Err(c);\n                    }\n                }\n            }\n            acc\n        };\n        flow_hh_logger::info!(\"Pre-checking Done\");\n        flow_hh_logger::info!(\"Storing pre-checking results\");\n        C::store_precheck_result(precheck_result);\n        flow_hh_logger::info!(\"Storing pre-checking results Done\");\n        flow_hh_logger::info!(\"Checking+Codemodding {} files\", _roots.len());\n        let options = C::check_options(_options.clone());\n        let metadata =\n            flow_typing_context::mk_context_metadata(&options, _env.master_cx.global_libdefs());\n        let visit_fn: &(\n             dyn Fn(\n            &Options,\n            &ast::Program<Loc, Loc>,\n            codemod_context::typed::TypedCodemodContext<'_>,\n        ) -> Self::Accumulator\n                 + Sync\n         ) = &C::visit;\n        let (mut inner, cache) = flow_services_inference::merge_service::mk_check(\n            reader.clone(),\n            Arc::new(options.clone()),\n            _env.configured_libs(),\n            &_env.master_cx,\n            flow_services_references::find_refs_types::empty_request(),\n        );\n        let mut check_fn = |file: FileKey| {\n            post_check(\n                visit_fn,","sourceCodeStart":1179,"sourceCodeEnd":1215,"githubUrl":"https://github.com/facebook/flow/blob/21c11b2eada01107bc3a459b0e99a7e56a502ddc/rust_port/crates/flow_codemods/src/utils/codemod_runner.rs#L1179-L1215","documentation":"During codemod initialization the runner does `workers.as_ref().expect(\"workers required for init\")`. `Genv.workers` is built by `make_genv`, which creates a thread pool only when `options.max_workers > 0` and sets `None` when `max_workers == 0`. Typed codemod runners need that pool for `init_from_scratch`, so a zero-worker configuration panics here.","triggerScenarios":"Launching the codemod binary with `--max-workers 0` (or a config/env override that zeroes max_workers); building a Genv manually with max_workers=0 and then running a runner that requires a pool.","commonSituations":"Users passing `--max-workers 0` intending single-threaded execution; flag values copied from other tools where 0 means auto; tests embedding the runner with a minimal Genv.","solutions":["Run the codemod without `--max-workers 0`, or pass an explicit `--max-workers N` with N >= 1.","Trace where max_workers becomes 0 (CLI flag parsing, .flowconfig, environment) and fix the value.","If constructing the environment in code, use `make_genv` with max_workers >= 1 so a pool is created."],"exampleFix":"// before\nlet pool = workers.as_ref().expect(\"workers required for init\");\n\n// after\nlet Some(pool) = workers.as_ref() else {\n    eprintln!(\"codemod requires at least one worker (max_workers is 0); pass --max-workers >= 1\");\n    std::process::exit(2);\n};","handlingStrategy":"validation","validationCode":"// Before launching the codemod, reject a zero worker configuration\nif options.max_workers < 1 {\n    eprintln!(\"codemod requires max_workers >= 1 (got {})\", options.max_workers);\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"let Some(pool) = workers.as_ref() else {\n    eprintln!(\"max_workers is 0; pass --max-workers >= 1\");\n    std::process::exit(2);\n};","preventionTips":["Never pass --max-workers 0 to codemod binaries; omit the flag to use the default pool.","Validate max_workers at configuration load time, not deep in the runner.","When embedding the runner, build Genv via make_genv with max_workers >= 1."],"tags":["codemod","configuration","thread-pool","max-workers"],"backgroundTag":"invalid-config-value","analyzedSha":"21c11b2eada01107bc3a459b0e99a7e56a502ddc","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}