Skip to content

fix: retry sfw vp install when sfw misreports vp as not found on Windows - #120

Merged
fengmk2 merged 3 commits into
mainfrom
fix/sfw-windows-not-found-retry
Aug 6, 2026
Merged

fix: retry sfw vp install when sfw misreports vp as not found on Windows#120
fengmk2 merged 3 commits into
mainfrom
fix/sfw-windows-not-found-retry

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Fixes the recurring Windows flake where sfw vp install fails with Command 'vp' not found in PATH ~10.5s after spawn while vp is installed and on PATH (seen in this repo's CI and downstream, e.g. node-modules/urllib#859).

Root cause (from the bundled JS inside the sfw-free v1.15.0 binary): on Windows, sfw's resolveWindowsCommand resolves the wrapped command by running powershell.exe -NoProfile -Command "Get-Command vp ..." through child_process.exec with a hard timeout: 10000. When a cold PowerShell start plus Get-Command module discovery exceeds 10s, exec kills the lookup, sfw swallows the error and throws the misleading not-found message. A genuine not-found returns in ~1s, so the ~10.5s timing identifies the timeout path.

Change in runViteInstall: when an sfw-wrapped install fails with that exact signature, log a warning, warm the PowerShell command cache with an uncapped Get-Command vp (Windows only), then retry the install once. The retry runs against warm caches and fits sfw's 10s window. Healthy runs see no extra work, non-matching failures still fail immediately, and a genuinely missing vp fails on the retry.

Tests cover the retry, the warm-up call shape, single-retry limit, non-matching failures, sfw-disabled runs, and a throwing warm-up. Worth filing upstream at SocketDev/sfw-free so the timeout itself gets fixed; this retry keeps CI green meanwhile.

sfw resolves the wrapped command on Windows via powershell.exe Get-Command
with a hard 10s child-process timeout (sfw-free v1.15.0,
resolveWindowsCommand). A cold PowerShell start can exceed that, and sfw
reports the killed lookup as "Command 'vp' not found in PATH" even though
vp is installed, failing the job ~10.5s after spawn.

When an sfw-wrapped install fails with that exact signature, warm the
PowerShell command cache with an uncapped Get-Command lookup, then retry
the install once. Healthy runs see no overhead; a genuinely missing vp
still fails on the retry.
@fengmk2 fengmk2 self-assigned this Aug 5, 2026
@fengmk2

fengmk2 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@codex review

fengmk2 added 2 commits August 6, 2026 09:57
A single warmed retry can still lose the race on a heavily loaded runner.
Keep retrying while the exact flake signature persists, up to 3 retries,
warming the PowerShell command cache before each one. Any other failure
still stops the loop immediately.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: f142b4a3c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fengmk2
fengmk2 marked this pull request as ready for review August 6, 2026 03:02
Copilot AI review requested due to automatic review settings August 6, 2026 03:02
@fengmk2
fengmk2 merged commit f1b914b into main Aug 6, 2026
163 checks passed
@fengmk2
fengmk2 deleted the fix/sfw-windows-not-found-retry branch August 6, 2026 03:03

Copilot AI 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.

Pull request overview

This PR mitigates a recurring Windows CI flake where sfw vp install incorrectly fails with Command 'vp' not found in PATH due to a 10s PowerShell resolution timeout inside sfw-free, by adding a one-time retry path that warms PowerShell’s command cache on Windows.

Changes:

  • Add flake signature detection and a best-effort Windows PowerShell warm-up helper in runViteInstall.
  • Retry sfw vp install once when the specific “vp not found” signature is observed.
  • Add unit tests covering the retry behavior and edge cases; update the bundled dist/index.mjs.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/run-install.ts Adds sfw flake detection, PowerShell warm-up, and single retry logic in runViteInstall.
src/run-install.test.ts Adds tests validating retry/warm-up behavior and non-matching failure handling.
dist/index.mjs Updates the compiled action bundle to include the new retry logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/run-install.ts
Comment on lines +75 to +77
warning(
"sfw reported vp as not found even though it is on PATH. This is a known sfw flake on Windows: a cold PowerShell start exceeds sfw's 10s command-resolution timeout and the timeout is misreported as not-found. Warming the PowerShell command cache and retrying once.",
);
Comment thread src/run-install.ts
Comment on lines +27 to +29
await getExecOutput("powershell.exe", ["-NoProfile", "-Command", "Get-Command vp"], {
ignoreReturnCode: true,
});
@fengmk2 fengmk2 mentioned this pull request Aug 6, 2026
fengmk2 added a commit that referenced this pull request Aug 6, 2026
Bump the version to v1.17.0 in package.json, the README examples, and
the setup-ref / setupRef defaults in the GitLab and Azure templates.

Changes since v1.16.1:

- feat: support disabling Vite+'s Node.js management with node-manager:
false (#115)
- fix: retry sfw vp install when sfw misreports vp as not found on
Windows (#120)
- chore(deps): update vite-plus to v0.2.8 (#119)
- ci: re-run bundle rebuild when Renovate pushes to a labeled PR (#122)
- chore: align Renovate release age for the whole vite-plus group (#121)

After merge, tag the merge commit as v1.17.0 and push the tag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants