Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

fix(windows): ensure installed-smoke cleanup closes all Electron children and frees local port

davoodmehraban89 committed Oct 17, 2026 at 02:17 UTC 332d3e74ca45a91d548c93b8ac7264f5ce88649d
1 file changed +14
scripts/windows-vm-treasury-install-smoke.ps1
+14
@@ -62,5 +62,19 @@ try {
62 throw
63 }finally {
64 if($p -and !$p.HasExited){try{& taskkill.exe /T /F /PID $p.Id | Out-Null}catch{}}
65 + # NSIS and Electron can spawn an additional real app or NODE child process.
66 + # The next CDP test must start from a clean disposable VM and free local port.
67 + $orphans=@(Get-Process -Name 'TreasuryFlow' -ErrorAction SilentlyContinue)
68 + $report.cleanupProcessCount=$orphans.Count
69 + foreach($orphan in $orphans){try{Stop-Process -Id $orphan.Id -Force -ErrorAction Stop}catch{}}
70 + $clear=$false
71 + for($attempt=0;$attempt -lt 30;$attempt++){
72 + $listeners=@(Get-NetTCPConnection -LocalPort 3210 -State Listen -ErrorAction SilentlyContinue)
73 + if($listeners.Count -eq 0){$clear=$true;break}
74 + Start-Sleep -Milliseconds 500
75 + }
76 + $report.localPort3210Freed=$clear
77 + if(!$clear){$report.outcome='FAIL_CLEANUP_PORT_OCCUPIED'}
78 $report|ConvertTo-Json -Depth 4|Set-Content (Join-Path $evidenceDir 'installed-runtime.json') -Encoding UTF8
79 + if(!$clear){throw 'INSTALLED_SMOKE_LEFT_PORT_3210_OCCUPIED'}
80 }