Skip to content

Windows tree tests start their ping through .NET: the cancel test no longer waits for PowerShell to read every module - #55

Merged
undistracted2cha merged 6 commits into
masterfrom
fix/windows-cancel-test
Oct 16, 2026
Merged

undistracted2cha merged 6 commits into
masterfrom
fix/windows-cancel-test

Conversation

@undistracted2cha

Copy link
Copy Markdown
Contributor

sys::tests::windows_cancel_kills_the_whole_tree failed at random on Windows ("the ping never started", 3 of ~60 runs: 38852822160, 38816142679, 38745678952).

Cause (measured on fresh windows-latest VMs)

  • The runner image sets PSModuleAnalysisCachePath=C:\PSModuleAnalysisCachePath\ModuleAnalysisCache, a prebuilt module cache. The cancel test starts PowerShell through run_isolated with a short environment, which drops it, and the per-user default cache does not exist on the runner.
  • Before its first cmdlet (Start-Process), Windows PowerShell then reads every module on its path (Az 15.6.1 and the rest). Stack of the stuck PowerShell: CommandDiscovery.TryModuleAutoDiscovery → AnalysisCache.AnalyzeManifestModule → Get-Module -ListAvailable → LoadBinaryModule.
  • Finding Start-Process: 22–60 s alone, 12–75 s while the other tests run; 0.1 s with the variable passed through. PowerShell saves its cache only seconds after the analysis, so a PowerShell the test kills right away never saves it: every run paid again. Past 60 s the watcher panicked without cancelling, and the test sat on until run_isolated's 120 s limit.

Not a run_isolated defect: it passes exactly the environment it is given. On a user's PC the default cache is in the profile and warm, and the app's isolated program (Claude Code) is not PowerShell.

Change (tests only)

  • The tree script uses .NET calls only (Process.Start with ShellExecute and a hidden window, File.WriteAllText): no module discovery, whatever the environment.
  • wait_for_pid returns None instead of panicking. The cancel test cancels in every case, and both tree tests fail with PowerShell's output, its exit code and the elapsed time.

Proof (temporary workflow on this branch, removed in the last commit)

  • 65 full cargo test --lib runs on 5 fresh VMs, no failure (38860347014).
  • Suite without the 20 s timeout test: 3.3 s at most; cancel test alone: 0.6 s (30 + 30 runs, 38861180600). Before: 12–75 s for the cancel test (38855348805, 38858791739).

@undistracted2cha
undistracted2cha merged commit 0ea0512 into master Oct 16, 2026
17 checks passed
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.

1 participant