{"record":{"id":"0961d7fd3ef41adb","repo":"facebook/flow","slug":"flow-check-failed","errorCode":null,"errorMessage":"Flow check failed!","messagePattern":"Flow check failed!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/flow-dev-tools/src/errors.js","lineNumber":51,"sourceCode":"      format(\n        '%s status --no-auto-start --json %s %s',\n        bin,\n        flowconfigNameFlag,\n        root,\n      ),\n  };\n  const [err, stdout, stderr] = await execManual(cmd, {\n    cwd: root,\n    maxBuffer: Infinity,\n  });\n\n  // 0 - no errors\n  // 2 - Some errors\n  if (err == null || err.code === 2) {\n    return JSON.parse(stdout.toString());\n  }\n\n  throw new Error(format('Flow check failed!', err, stdout, stderr));\n}\n\nasync function getFlowErrors(\n  bin: string,\n  errorCheckCommand: ErrorCheckCommand,\n  root: string,\n  flowconfigName: string,\n): Promise<FlowResult> {\n  return getFlowErrorsImpl(bin, errorCheckCommand, root, flowconfigName);\n}\n\nfunction mainSourceLocOfError(error: FlowError): ?FlowLoc {\n  const {operation, message} = error;\n  for (const msg of [operation, ...message]) {\n    if (msg && msg.loc && msg.loc.type === 'SourceFile') {\n      return msg.loc;\n    }\n  }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/packages/flow-dev-tools/src/errors.js#L33-L69","documentation":"flow-dev-tools runs `<bin> full-check --json --flowconfig-name <name> <root>` and treats exit code 0 (clean) and 2 (errors reported as JSON) as success. Any other exit code — crash, internal error, binary missing, OOM kill — throws 'Flow check failed!' with the process error, stdout, and stderr attached for diagnosis.","triggerScenarios":"getFlowErrors with a flow binary that exits nonzero other than 2: flow internal error (exit 1), binary not found (spawn ENOENT), server crash or SIGABRT/SIGKILL (OOM), or a .flowconfig option the installed flow version rejects at startup.","commonSituations":"CI scripts or dist-tooling invoking getFlowErrors after a flow upgrade that changed flowconfig semantics; flow daemon corrupted after a version switch (needs flow stop / server cleanup); system OOM on huge repos; flow not installed at the configured bin path.","solutions":["Copy the failing command from the error output (bin full-check --json ...) and run it manually to see the real stderr.","Check the installed flow version matches what the .flowconfig and repo expect; upgrade/downgrade flow-bin consistently.","Run `flow stop` (or delete .flowconfig-magic) to clear a stale daemon, then retry.","Verify the bin path exists and is executable (which flow; npm ls flow-bin).","If OOM, raise available memory or scope the check to fewer files."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the flow binary runs before asking it for errors\nconst {execFileSync} = require('child_process');\nfunction flowBinaryWorks(bin) {\n  try { execFileSync(bin, ['version'], {stdio: 'ignore'}); return true; }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const errors = await getFlowErrors(bin, 'full-check', root, '.flowconfig');\n} catch (e) {\n  if (e.message.startsWith('Flow check failed!')) {\n    // err/stdout/stderr are embedded — extract and surface them, then fail the step\n    console.error(e.message);\n    throw new Error('flow exited abnormally — run the printed command manually to diagnose');\n  }\n  throw e;\n}","preventionTips":["Pin flow-bin and run `flow version` as a CI smoke step before full-check.","Keep .flowconfig options compatible with the installed flow version; check the changelog on upgrades.","After upgrading flow, run `flow stop` to clear daemons before CI checks."],"tags":["flow","cli","exit-code","flow-dev-tools","ci"],"backgroundTag":"cli-exit-code-error","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}