Skip to content

[scripts] Bug Fix: Fix Flow execution on Windows and propagate process failures - #10029

Open
christdh213-droid wants to merge 1 commit into
meta:mainfrom
christdh213-droid:fix/windows-flow-spawn
Open

christdh213-droid wants to merge 1 commit into
meta:mainfrom
christdh213-droid:fix/windows-flow-spawn

Conversation

@christdh213-droid

Copy link
Copy Markdown

Description

pnpm run flow fails on Windows with spawn EINVAL because scripts/check-flow-types.mjs attempts to execute the flow.cmd shim without a shell. Node.js rejects this following the security hardening associated with CVE-2024-27980.

This PR resolves the native executable exported by flow-bin directly, following an existing pattern in keyboardShortcutFlow.test.ts, without introducing shell execution or additional dependencies.

It also improves failure handling in the same execution path:

  • Handles synchronous and asynchronous startup failures explicitly.
  • Prevents false-success exit statuses under non-default unhandled-rejection configurations.
  • Preserves Flow's nonzero exit status.
  • Returns a nonzero status when Flow is terminated by a signal.
  • Uses process.exitCode to allow diagnostic output to drain.
  • Prevents duplicate failure diagnostics.

The existing arguments, working directory, environment and inherited stdio behavior are preserved.

Closes #10028.

Related: #9936.

Changeset

None required. This change affects repository development tooling only and does not modify published packages or public APIs.

Test plan

Before

On Windows 11 x64 with Node.js v24.19.0 and pnpm 11.24.0:

Running Flow...
Error: spawn EINVAL

Exit code: 1.

Synchronous startup failures could also return exit code 0 under --unhandled-rejections=warn or none.

After

The real Flow check completes successfully:

Running Flow...
Found 0 errors

Exit code: 0.

An isolated project containing a deliberate Flow type error correctly returned exit code 2.

Added seven process-level regression tests covering:

  • Exact argument forwarding and inherited environment, working directory and output streams.
  • Preservation of Flow's exit status.
  • Failed executable startup with a single diagnostic.
  • Unsupported platform handling.
  • Missing flow-bin under non-default unhandled-rejection configurations.
  • Synchronous spawn failures under non-default unhandled-rejection configurations.
  • Signal termination.

Validation

  • New regression tests against original upstream implementation: 6 failed, 1 skipped.
  • New regression tests against corrected implementation: 6 passed, 1 skipped.
  • ESLint on changed files: passed.
  • Prettier on changed files: passed.
  • Script TypeScript checking: passed.
  • Git diff whitespace checks: passed.

Known limitations

  • Local validation was performed on Windows 11 x64 with Node.js v24.19.0.
  • The POSIX-only signal regression test was skipped on Windows.
  • Linux, macOS and Node.js 22 remain unverified locally.
  • An earlier full scripts-suite run identified 10 failures that were also present on the unmodified baseline. The complete suite was not rerun after the final corrections.
  • Dependencies were installed with --ignore-scripts; the standard installation and Husky hook workflow were not verified.
  • Installed tool entry points were used during independent validation because of a Corepack registry DNS failure.

AI assistance

Claude Code was used for implementation and validation. OpenAI Codex independently reviewed the implementation, identified failure-handling defects, and verified the subsequent corrections. The author personally reran the Flow check, targeted regression tests, formatting and script TypeScript checks.

Addresses meta#10028 by executing the native flow-bin binary directly and handling startup failures and signal termination. Add process-level regression tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Dec 2, 2026 9:00pm UTC
lexical-playground Ready Ready Preview Dec 2, 2026 9:00pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 2, 2026
@rootnode-bot

rootnode-bot Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 2, 2026, 9:10 PM UTC

@rootnode-bot rootnode-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good. Running the binary that flow-bin exports is the right fix for the Windows spawn EINVAL. It matches how scripts/__tests__/unit/keyboardShortcutFlow.test.ts already runs Flow, and it keeps shell execution out of the picture.

Reproduced locally on Linux:

  • The new tests pass (7/7).
  • pnpm run flow on this branch prints Found 0 errors and exits 0.
  • The script exits 2 on a project with a deliberate type error.

The change also fixes a POSIX case the description doesn't mention. When Flow is killed by a signal, the old path through flow-bin's cli.js exits 0; this branch exits 1 with Flow was terminated by SIGKILL :(.

Optional, non-blocking:

  • PR title: AGENTS.md ("Commits and Pull Requests") says "Test-only and tooling changes are Chore", and the bracketed part names directories under packages/. A Chore: title fits that convention better than [scripts] Bug Fix:, and it can also be adjusted at merge.
  • Test plan: AGENTS.md asks for pasted Before/After output rather than a description. CI runs the scripts unit tests on Linux only, so pasting the vitest output behind your "6 failed, 1 skipped" and "6 passed, 1 skipped" Windows runs would make the Windows evidence self-contained.

No changeset is needed for a tooling-only change (AGENTS.md and the pull request template both say so).

Automated review (maintainer link)

This branch was successfully deployed

2 active deployments
Preview – lexical — 5e998b8f Deployed Dec 2, 2026 by vercel[bot]
Preview – lexical-playground — 5e998b8f Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: pnpm run flow fails on Windows with spawn EINVAL

1 participant