fix(macos): allow XCTest teardown before runner kill#1206
Conversation
|
Review found one P2 scope gap: HTTP/proxy macOS disconnects still do not invoke runner abort. Extend disconnect abort routing to the macOS runner without changing iOS/tvOS cancellation semantics, add an HTTP disconnect regression, and provide SHA-pinned evidence for that boundary. Not auto-fixing because this is an external contributor branch. |
|
macOS HTTP/proxy disconnects now route through runner abort and reach the staged
|
|
Reviewed — solid, well-scoped fix. 👍 The staged SIGINT → wait 5s → SIGTERM → wait 2s → SIGKILL teardown for macOS is correct: escalation only ever targets survivors, and the conservative delay is properly isolated to macOS active sessions — prep processes and iOS/tvOS keep immediate cancellation, so the added latency only applies where it protects host screen-saver state. The Non-blocking nits (all optional):
Good to merge as-is. |
|
Thank you so much @lott-ai and congrats on first contribution! Hopefully more to come :D |
Fixes #1205
Summary
SIGINT, wait,SIGTERM, wait, thenSIGKILLonly if still necessaryProblem
XCTest disables the host screen saver while macOS UI automation is running. The runner abort path previously sent
SIGINT,SIGTERM, andSIGKILLback-to-back, which could terminatexcodebuildbefore XCTest restored the screen-saver permission.When a client disconnected during an in-flight request, macOS could therefore remain at
setScreenSaverCanRun: 0. Dock still recognized the configured hot-corner action, butloginwindowrefused to start the screen saver.Implementation
macOS runner disposal now:
SIGINTand waits up to five seconds for XCTest teardown;SIGTERMonly to runners that remain alive and waits another two seconds; andSIGKILLonly to runners still alive after both grace periods.The wait helper now reports whether the runner exited and clears its timeout when the test process settles. Graceful-shutdown fallback also reuses the staged macOS path without waiting for the same process twice.
The conservative delay is isolated to macOS because it protects host-wide screen-saver state. Other Apple targets retain their previous immediate abort behavior.
Validation
Automated checks:
pnpm exec vitest run --project unit-core src/platforms/apple/core/__tests__/runner-disposal.test.ts pnpm check:affected --base origin/main --runAll four focused regression tests and all nine affected checks passed.
Manual fault-path validation on macOS:
Installed the package built from this branch as the active global agent-device CLI.
Started a TextEdit snapshot so the macOS XCTest runner was active.
Terminated the client while the request was in flight.
Confirmed the runner process was cleaned up and no automation marker remained.
Confirmed the same
xcodebuildprocess restored the loginwindow state:The interrupted runner cleaned up in approximately 1.6 seconds, without requiring TERM or KILL escalation.