Kill only this run's browser on the remote host
Both shutdown paths ran Get-Process chrome,msedge | Stop-Process -Force, which is every browser on the machine. The remote host is somebody's desktop: a test run must not close the windows they are working in. It only stayed harmless because the test account cannot touch another user's processes. The launcher now writes its browser pid to %TEMP%\gm-browser-<port>.pid and kills that pid; the job object still takes the renderer children. Measured against the Windows desktop: five msedge processes belonging to the logged-in user before the run, five after, and our chrome gone. 24 smoke checks ALL PASSED.
This commit is contained in:
1 parent
dd2ea8c761
commit
1bd6e89ff5
2 files changed
+13
-5
No files matched your search
@@ -103,16 +103,18 @@ export function launchBrowser({ port, width, height }) {
|
||||
/**
|
||||
* The launcher notices a finished run on its own, but only after its idle window – a browser
|
||||
* lingering a minute on someone else's desktop is rude, so end it now and let that window be
|
||||
* the net for runs that die without reaching here.
|
||||
* the net for runs that die without reaching here. Only this run's pid: the host is somebody's
|
||||
* desktop, and killing by name would close the browser they are reading this in.
|
||||
*/
|
||||
stop: () => {
|
||||
const pidFile = `$env:TEMP\\gm-browser-${port}.pid`;
|
||||
try {
|
||||
execFileSync(
|
||||
'ssh',
|
||||
[
|
||||
...sshArgs(key),
|
||||
remote,
|
||||
'powershell -NoProfile -Command "Get-Process chrome,msedge -ErrorAction SilentlyContinue | Stop-Process -Force"',
|
||||
`powershell -NoProfile -Command "if (Test-Path ${pidFile}) { Stop-Process -Id (Get-Content ${pidFile}) -Force -ErrorAction SilentlyContinue }"`,
|
||||
],
|
||||
{ stdio: 'pipe', timeout: 20_000 },
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user