Skip to content

fix(vibe-tests): run tsx through cmd.exe on Windows in public-artifact-cli.test.mjs - #5908

Merged
cixzhang merged 1 commit into
facebook:mainfrom
HelloOjasMutreja:fix/vibe-tests-tsx-spawn-windows
Sep 3, 2026
Merged

fix(vibe-tests): run tsx through cmd.exe on Windows in public-artifact-cli.test.mjs#5908
cixzhang merged 1 commit into
facebook:mainfrom
HelloOjasMutreja:fix/vibe-tests-tsx-spawn-windows

Conversation

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor

Problem

public-artifact-cli.test.mjs spawns node_modules/.bin/tsx directly via spawnSync(TSX, [script, ...args], {cwd, encoding: 'utf8'}). pnpm generates tsx.cmd on Windows (a batch shim), not a bare tsx executable, and spawnSync can't run a batch file without a shell. The spawn fails silently: result.status comes back null instead of a real exit code, result.stderr stays empty. Both tests asserting result.status to be 0 fail as a result.

Confirmed on a real Windows run before the fix: npx vitest run internal/vibe-tests/setup-test/public-artifact-cli.test.mjs --project node, 2 of 10 tests failing with expected null to be +0.

Fix

Shells out through cmd.exe /c instead, matching the established pattern for pnpm elsewhere in this package. Needed two things beyond that baseline pattern, both required together (confirmed by testing simpler combinations first and watching them fail differently):

  • Quote each argument, join into one command-line string. cmd.exe /c doesn't receive Node's argv array as discrete arguments; it reconstructs one string from them and reparses it with its own rules. This suite deliberately exercises a path containing a space (a "setup report <pid>" tmpdir), which gets split apart before tsx ever sees it without this.
  • windowsVerbatimArguments: true. Without it, spawnSync re-quotes/escapes that already-quoted command-line string as if it were a single plain argument (since cmd.exe is, to Node, just another regular executable), corrupting the quotes before cmd.exe ever sees them.

Testing

  • Ran the actual test file, not just the source: both previously-failing tests now pass.
  • Ran the full internal/vibe-tests/setup-test/ suite: 116/124 passing (8 skipped, the unrelated env-gated canonical suite), up from 114 before this fix.
  • eslint clean (the file matches this package's existing eslint ignore pattern, same as the other internal/vibe-tests scripts touched in prior PRs).

Related to the same root-cause bug class already fixed for pnpm in #5841 and #5843.

…t-cli.test.mjs

The suite spawned node_modules/.bin/tsx directly via spawnSync. pnpm
generates tsx.cmd on Windows (a batch shim), which spawnSync can't run
without a shell, so the spawn silently failed: result.status came
back null instead of a real exit code, both tests asserting on it
failed.

Shells out through cmd.exe /c instead, matching the pattern already
used for pnpm elsewhere in this package. Needed two things beyond that
baseline pattern, both required together (verified by testing simpler
combinations first): quoting each argument before joining them into a
single command-line string, since cmd.exe /c reconstructs one string
from the args array rather than receiving them as discrete arguments
and this suite deliberately exercises a path containing a space (a
"setup report <pid>" tmpdir); and windowsVerbatimArguments so
spawnSync doesn't re-quote that already-quoted string as if it were
one plain argument, which corrupted it before cmd.exe ever saw it.

Verified by running the actual test file, not just reading the
source: both previously-failing tests now pass, and the full
internal/vibe-tests/setup-test/ suite is 116/124 passing (8 skipped,
unrelated env-gated canonical suite), up from 114 before this fix.
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 2, 2026 7:22am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 2, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Sep 2, 2026
github-actions Bot added a commit that referenced this pull request Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this is a clean compatibility fix. The explicit cmd.exe call matches Node’s Windows batch-file contract while keeping every shell argument fixed or test-generated.

[Reviewed by Robohands]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 3, 2026
@cixzhang
cixzhang enabled auto-merge (squash) September 3, 2026 21:11
@cixzhang
cixzhang merged commit 03feefd into facebook:main Sep 3, 2026
28 checks passed
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 Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants