{"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/d1341dac899a79c027762f6b423d896045287620/packages/flow-dev-tools/src/errors.js#L33-L69","documentation":"flow-dev-tools runs the Flow binary (execManual) and treats exit code 0 (clean) and 2 (type errors reported) as success. Any other exit code — crash, bad usage, missing binary, signal death — causes 'Flow check failed!' to be thrown with the captured stdout/stderr.","triggerScenarios":"The spawned flow command (e.g. `flow check --json` or a configured errorCheckCommand) exits with a code other than 0 or 2: flow-bin missing or not executable, a flow version incompatible with the repo's .flowconfig, a flow daemon crash or OOM, invalid flowconfig, or a custom errorCheckCommand that exits non-zero.","commonSituations":"Running flow-dev-tools scripts on machines without flow-bin installed; .flowconfig [version] header not matching the installed flow; a crashed flow server leaving stale state; CI containers lacking memory or native deps for flow.","solutions":["Run the exact underlying command shown in the error output manually (e.g. `npx flow check --json --strip-root`) to see the real failure","Verify flow-bin is installed and runnable: `npm ls flow-bin` and `npx flow version`","Align versions: the number in .flowconfig's [version] section must match the installed flow-bin","If flow crashed, stop the server (`npx flow stop`) and retry; give CI more memory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import {execFileSync} from 'child_process';\n\nfunction flowBinaryWorks(flowPath: string): boolean {\n  try {\n    const out = execFileSync(flowPath, ['version'], {encoding: 'utf8'});\n    return /Flow\\s+v?\\d/.test(out);\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await getFlowErrors(bin, cmd, root, flowconfigName);\n} catch (err) {\n  // the message embeds err/stdout/stderr: surface stderr to the user,\n  // distinguish 'command not found' vs flow diagnostics vs crash\n  throw new Error(`Flow invocation failed: ${err.message}`);\n}","preventionTips":["Pin the exact flow-bin version matching .flowconfig in CI","Add a `npx flow version` smoke step before dependent jobs","Run `npx flow stop` when a server crash is suspected","Keep errorCheckCommand flags valid for the installed flow version"],"tags":["flow","cli","process-exit","dev-tools","spawn"],"backgroundTag":"cli-tool-exit-code-nonzero","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}