mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
* perf(worktree): remove redundant creation and terminal startup work * test(worktree): cover optimized creation call signatures Preserve explicit branch adoption, WSL callback routing and sparse cleanup expectations. * perf: preserve user Git checkout worker settings * perf(git): skip malformed remote base probes * perf(cli): avoid loading other agent hooks for Codex preflight * fix(build): retain Codex preflight entry for packaged CLI * test(ssh): wait for replacement PTY before lease recovery input * test(ssh): verify recovered shell execution and lease ownership * test(electron): reap isolated macOS crash reporters on teardown * test: allow either observed self-exit snapshot ordering * test: capture frozen-host input recovery evidence
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { execFileSync } from 'node:child_process'
|
|
import path from 'node:path'
|
|
|
|
function ownsCrashpad(command: string, userDataDir: string): boolean {
|
|
return (
|
|
command.includes('/chrome_crashpad_handler ') &&
|
|
command.includes(` --database=${path.join(userDataDir, 'Crashpad')} `)
|
|
)
|
|
}
|
|
|
|
export function cleanupE2ECrashpad(userDataDir: string): void {
|
|
if (process.platform !== 'darwin') {
|
|
return
|
|
}
|
|
|
|
// macOS reparents Crashpad before app exit; its inherited stderr can keep Playwright open.
|
|
try {
|
|
const table = execFileSync('ps', ['-axo', 'pid=,command='], {
|
|
encoding: 'utf8',
|
|
timeout: 5_000
|
|
})
|
|
for (const row of table.split('\n')) {
|
|
const match = row.match(/^\s*(\d+)\s+(.+)$/)
|
|
if (!match || !ownsCrashpad(match[2], userDataDir)) {
|
|
continue
|
|
}
|
|
const pid = Number(match[1])
|
|
if (!Number.isSafeInteger(pid) || pid <= 1) {
|
|
continue
|
|
}
|
|
try {
|
|
const command = execFileSync('ps', ['-p', String(pid), '-o', 'command='], {
|
|
encoding: 'utf8',
|
|
timeout: 5_000
|
|
})
|
|
if (ownsCrashpad(command, userDataDir)) {
|
|
process.kill(pid, 'SIGTERM')
|
|
}
|
|
} catch {
|
|
// The test-owned reporter may already have exited.
|
|
}
|
|
}
|
|
} catch {
|
|
// Cleanup remains best-effort when process enumeration is unavailable.
|
|
}
|
|
}
|