Skip to content

The agent that grows with you

fix(windows-e2e): AHK helper wedged on invalid stdout handle before clicking Install

ethernetb685efed678d
diff --git a/tests/install/windows/install-hermes-desktop.ahk b/tests/install/windows/install-hermes-desktop.ahk
index 2cd8338c32c..dedf4ce752e 100644
--- a/tests/install/windows/install-hermes-desktop.ahk
+++ b/tests/install/windows/install-hermes-desktop.ahk
@@ -18,7 +18,13 @@ logPath := A_Args.Length >= 1 ? A_Args[1] : "ahk.log"
Log(text) {
msg := Format("[autohotkey] {}`n", text)
ToolTip(text)
- FileAppend(msg, '*')
+ ; stdout only exists when the launcher attached a console (Start-Process
+ ; -NoNewWindow). AutoHotkey64 is a GUI-subsystem exe, so a bare spawn has
+ ; an invalid stdout handle and FileAppend('*') throws "(6) The handle is
+ ; invalid" -- recursively, from inside OnError's own Log call, which
+ ; wedges the script instead of exiting. The log FILE is the record;
+ ; stdout is best-effort.
+ try FileAppend(msg, '*')
FileAppend(msg, logPath)
}
diff --git a/tests/install/windows/install-update-e2e.ps1 b/tests/install/windows/install-update-e2e.ps1
index e7e2bec60d3..2b4884e5744 100644
--- a/tests/install/windows/install-update-e2e.ps1
+++ b/tests/install/windows/install-update-e2e.ps1
@@ -211,7 +211,9 @@ $installerOk = $false
try {
$proc = Start-Process -FilePath $InstallerPath -PassThru
$ahkLog = Join-Path $LogDir "ahk.log"
- $ahkProc = Start-Process -FilePath "AutoHotkey64.exe" `
+ # -NoNewWindow attaches our console as the GUI-subsystem exe's stdout so
+ # the helper's live lines land in the job log as they happen.
+ $ahkProc = Start-Process -FilePath "AutoHotkey64.exe" -NoNewWindow `
-ArgumentList "`"$PSScriptRoot\install-hermes-desktop.ahk`"", "`"$ahkLog`"" -PassThru
# Tail the bootstrap log into the job log while we wait: the install IS