{"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":1255,"sourceCode":"            _roots.iter().cloned().collect();\n        updates.add(Some(focused_set), None, None);\n        let find_ref_request = flow_services_references::find_refs_types::empty_request();\n        let files_to_force = flow_common_utils::checked_set::CheckedSet::empty();\n        let mut will_be_checked_files = flow_common_utils::checked_set::CheckedSet::empty();\n        let recheck_result = flow_services_inference::type_service::recheck(\n            pool,\n            &_genv.committed_heap,\n            &options_arc,\n            &updates,\n            &find_ref_request,\n            files_to_force,\n            false,\n            None,  // changed_mergebase\n            false, // missed_changes\n            &mut will_be_checked_files,\n            Arc::new(env),\n        );\n        let (_, _, _, prepared) = recheck_result.expect(\"recheck failed\");\n        let env = prepared.commit();\n        let transaction = ActiveTransaction::new(_genv.committed_heap.clone());\n        log_input_files(&_roots);\n        let results = TRC::merge_and_check(\n            &env,\n            workers,\n            options,\n            &profiling,\n            _roots,\n            _iteration,\n            &transaction.handle(),\n        )\n        .await?;\n        let env = EnvTransaction::new(env).into_env();\n        Ok(((), (env, results)))\n    }\n\n    #[allow(unreachable_code)]","sourceCodeStart":1237,"sourceCodeEnd":1273,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_codemods/src/utils/codemod_runner.rs#L1237-L1273","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":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-08-23T06:17:17.905Z"}