{"record":{"id":"6c3922ce831e92a8","repo":"facebook/flow","slug":"recheck-failed","errorCode":null,"errorMessage":"recheck failed","messagePattern":"recheck failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_codemods/src/utils/codemod_runner.rs","lineNumber":1258,"sourceCode":"    type Accumulator = TRC::Accumulator;\n\n    fn reporter() -> codemod_report::CodemodReport<Self::Accumulator> {\n        TRC::reporter()\n    }\n\n    #[allow(unreachable_code)]\n    async fn init_run(\n        _genv: &Genv,\n        heap: &Arc<CommittedHeap>,\n        _roots: BTreeSet<FileKey>,\n    ) -> Result<\n        ((), (Self::Env, ResultList<Self::Accumulator>)),\n        flow_utils_concurrency::worker_cancel::WorkerCanceled,\n    > {\n        let options = &*_genv.options;\n        let workers = &_genv.workers;\n        let should_print_summary = options.profile;\n        let profiling = profiling_start(\"Codemod\", should_print_summary);\n        let (heap_transaction, transaction, options_arc) =\n            with_memory_timer(options, \"CodemodInit\", || {\n                extract_flowlibs_or_exit(options);\n                let heap_transaction = ActiveTransaction::new(heap.clone());\n                let transaction = heap_transaction.handle();\n                let options_arc = Arc::new(options.clone());\n                (heap_transaction, transaction, options_arc)\n            });\n        let pool = workers.as_ref().expect(\"workers required for init\");\n        let root = &options.root;\n        // let%lwt (_libs_ok, env) = Types_js.init ~profiling ~workers options in\n        let (env, _libs_ok) = flow_services_inference::type_service::init_from_scratch(\n            &options_arc,\n            pool,\n            &transaction,\n            root,\n            None,\n        );","sourceCodeStart":1240,"sourceCodeEnd":1276,"githubUrl":"https://github.com/facebook/flow/blob/21c11b2eada01107bc3a459b0e99a7e56a502ddc/rust_port/crates/flow_codemods/src/utils/codemod_runner.rs#L1240-L1276","documentation":"The codemod's incremental recheck calls `type_service::recheck`, which returns `Err(RecheckError)` with variants `TooSlow` and `Canceled(files)`. Here it is invoked with `changed_mergebase: None`, and per the code comment TooSlim/TooSlow requires `changed_mergebase=Some(true)`, so a failure at this expect means `Canceled`: files changed unexpectedly on disk while the recheck was running.","triggerScenarios":"Autosave, formatter, git checkout, or another flow process rewrites files while the codemod is in its recheck/merge-check phase; long runs make the race window larger.","commonSituations":"IDE open with autosave during a long codemod; concurrent daemons (watchman, flow server, second codemod) on the same root; scripts mutating the repo in parallel with the codemod.","solutions":["Re-run the codemod on a quiesced repository — a transient concurrent edit is the normal cause.","Stop concurrent writers: `flow stop`, disable autosave/format-on-save, finish git operations first.","Serialize codemods per repository root.","For very large codemods, split into batches to shrink the window in which edits cancel the recheck."],"exampleFix":"// before\nlet (_, _, _, prepared) = recheck_result.expect(\"recheck failed\");\n\n// after\nlet (_, _, _, prepared) = match recheck_result {\n    Ok(r) => r,\n    Err(flow_services_inference::type_service::RecheckError::Canceled(files)) => {\n        eprintln!(\"{} files changed during recheck; re-run the codemod on a quiet repo\", files.len());\n        std::process::exit(2);\n    }\n    Err(other) => panic!(\"recheck failed: {other:?}\"),\n};","handlingStrategy":"retry","validationCode":"// Reduce the race window: confirm roots are quiet immediately before recheck\nfn roots_quiet(roots: &BTreeSet<FileKey>) -> bool {\n    let m = |f: &FileKey| std::fs::metadata(f.to_absolute()).ok().and_then(|x| x.modified().ok());\n    let a: Vec<_> = roots.iter().map(m).collect();\n    std::thread::sleep(std::time::Duration::from_millis(300));\n    roots.iter().map(m).eq(a.into_iter())\n}","typeGuard":null,"tryCatchPattern":"let (_, _, _, prepared) = match recheck_result {\n    Ok(r) => r,\n    Err(RecheckError::Canceled(files)) => {\n        eprintln!(\"{} files changed during recheck; re-run the codemod\", files.len());\n        std::process::exit(2);\n    }\n    Err(other) => panic!(\"recheck failed: {other:?}\"),\n};","preventionTips":["Stop concurrent writers (flow server, editors with autosave, git) for the whole codemod run.","Serialize codemods per root.","Commit before running so a canceled recheck loses nothing."],"tags":["codemod","recheck","concurrent-modification","canceled"],"backgroundTag":"concurrent-file-modification","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"}