facebook/flow · error

workers required for recheck

Error message

workers required for recheck

What it means

The codemod recheck step does `workers.as_ref().expect("workers required for recheck")`. As in the init step, `Genv.workers` is `None` exactly when `options.max_workers == 0` (`make_genv` only builds a pool for max_workers > 0); recheck requires the pool, so the zero-worker configuration panics here.

Source

Thrown at rust_port/crates/flow_codemods/src/utils/codemod_runner.rs:1234

    }

    #[allow(unreachable_code)]
    async fn recheck_run(
        _genv: &Genv,
        env: Self::Env,
        _iteration: i32,
        _roots: BTreeSet<FileKey>,
    ) -> Result<
        ((), (Self::Env, ResultList<Self::Accumulator>)),
        flow_utils_concurrency::worker_cancel::WorkerCanceled,
    > {
        let options = &*_genv.options;
        let workers = &_genv.workers;
        let should_print_summary = options.profile;
        let profiling = profiling_start("Codemod", should_print_summary);
        diff_heaps_remove_batch(&_roots);
        let options_arc = Arc::new(options.clone());
        let pool = workers.as_ref().expect("workers required for recheck");
        let mut updates = flow_common_utils::checked_set::CheckedSet::empty();
        let focused_set: flow_data_structure_wrapper::ord_set::FlowOrdSet<FileKey> =
            _roots.iter().cloned().collect();
        updates.add(Some(focused_set), None, None);
        let find_ref_request = flow_services_references::find_refs_types::empty_request();
        let files_to_force = flow_common_utils::checked_set::CheckedSet::empty();
        let mut will_be_checked_files = flow_common_utils::checked_set::CheckedSet::empty();
        let recheck_result = flow_services_inference::type_service::recheck(
            pool,
            &_genv.committed_heap,
            &options_arc,
            &updates,
            &find_ref_request,
            files_to_force,
            false,
            None,  // changed_mergebase
            false, // missed_changes
            &mut will_be_checked_files,

View on GitHub (pinned to f88ac94bcf)

Solutions

  1. Set max_workers to at least 1 (drop `--max-workers 0` or override it with `--max-workers N`).
  2. Audit the flowconfig/CLI/env chain that produces max_workers=0 and correct it.
  3. When building Genv programmatically, ensure `make_genv` sees max_workers > 0 before running recheck-based codemods.

Example fix

// before
let pool = workers.as_ref().expect("workers required for recheck");

// after
let Some(pool) = workers.as_ref() else {
    eprintln!("codemod recheck requires at least one worker (max_workers is 0)");
    std::process::exit(2);
};
Defensive patterns

Strategy: validation

Validate before calling

// Fail fast with a clear message instead of a panic inside recheck
assert!(options.max_workers >= 1,
    "codemod recheck requires max_workers >= 1 (got {})", options.max_workers);

Try / catch

let Some(pool) = workers.as_ref() else {
    eprintln!("recheck needs a worker pool; set max_workers >= 1");
    std::process::exit(2);
};

Prevention

When it happens

Trigger: Running a codemod with `--max-workers 0` or an equivalent config/env override; invoking the runner against a Genv built without a worker pool.

Common situations: Single-threaded intents expressed as `--max-workers 0`; config templates that zero out worker counts; test harnesses reusing a minimal Genv.

Related errors


AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20). Data as JSON: /api/errors/318dad65e427dd9e. Report an issue: GitHub.