ci(windows): make taskkill no-op when server.py already exited

The path-discovery step succeeds on the first run, but the cleanup
step exits non-zero because `taskkill /PID 5560 /T /F` returns 128
("process not found") when server.py has already exited on the mock
hermes_cli stub. That's the expected steady state for this mock-only
workflow, not a failure.

Two-line fix: reset `$global:LASTEXITCODE = 0` after the taskkill
call, and explicit `exit 0` at the end of the step so any other
external-command exit codes don't bubble up. The try/catch wrapper
didn't help because taskkill writes its diagnostic to stderr without
raising a PowerShell exception — `catch` never fired.

Run 26352805510 on this branch shows the failure shape: "OK: start.ps1
path discovery - all guards passed." in the verify step, then
"ERROR: The process '5560' not found." in the cleanup step. Path
discovery is what this workflow exists to validate; cleanup just has
to not fail the job.
This commit is contained in:
Dustin authored and nesquena-hermes committed 2026-05-24 17:10:02 +00:00
1 parent 145a442f61
commit ae6b6b1b72
1 file changed
+8 -8
+8 -8
View File
@@ -109,19 +109,18 @@ jobs:
} }
Write-Host "OK: start.ps1 path discovery - all guards passed." Write-Host "OK: start.ps1 path discovery - all guards passed."
# taskkill /T walks the process tree, /F forces. taskkill exits # taskkill /T walks the process tree, /F forces. taskkill returns
# non-zero if the PID is already gone (server.py crashed on the # 128 ("process not found") if the PID is already gone — that's
# stub) — that's expected, not a failure. # the expected steady state for this mock-only workflow because
# server.py exits immediately on the stub hermes_cli. Reset
# $LASTEXITCODE so the step never fails on the cleanup itself.
- name: Stop background server (tree-kill) - name: Stop background server (tree-kill)
if: always() if: always()
shell: pwsh shell: pwsh
run: | run: |
if ($env:SERVER_PID) { if ($env:SERVER_PID) {
try { & taskkill /PID $env:SERVER_PID /T /F 2>&1 | Out-Host
& taskkill /PID $env:SERVER_PID /T /F 2>&1 | Out-Host $global:LASTEXITCODE = 0
} catch {
Write-Host "taskkill: PID $env:SERVER_PID already exited (expected with mock stub)"
}
} }
# Belt-and-suspenders: kill anything still bound to 8787. # Belt-and-suspenders: kill anything still bound to 8787.
$hanging = Get-NetTCPConnection -LocalPort 8787 -State Listen -ErrorAction SilentlyContinue $hanging = Get-NetTCPConnection -LocalPort 8787 -State Listen -ErrorAction SilentlyContinue
@@ -130,3 +129,4 @@ jobs:
try { Stop-Process -Id $c.OwningProcess -Force -ErrorAction Stop } catch {} try { Stop-Process -Id $c.OwningProcess -Force -ErrorAction Stop } catch {}
} }
} }
exit 0