mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 11:05:31 +08:00
Merge pull request #13371 from Kilo-Org/research-windows-extension-performance-regression
fix(cli): avoid Windows PTY termination verification
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@kilocode/cli": patch
|
||||
---
|
||||
|
||||
Fix PTY cleanup on Windows when POSIX process-tree inspection is unavailable.
|
||||
@@ -153,7 +153,7 @@ export async function terminate(proc: Process, input: Runtime = runtime): Promis
|
||||
})
|
||||
if ((!killed || input.alive(proc.pid)) && !state.exited) direct(proc)
|
||||
if (!state.exited) await input.sleep(GRACE_MS)
|
||||
await verify(proc, state.exited, input)
|
||||
if (!state.exited && input.alive(proc.pid)) throw new Error(`PTY process tree is still alive: ${proc.pid}`)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ function runtime(
|
||||
taskkillLeavesAlive?: boolean
|
||||
signal?: "throw"
|
||||
tree?: Array<{ pid: number; parent: number }>
|
||||
treeError?: boolean
|
||||
treeCalls?: { count: number }
|
||||
} = {},
|
||||
) {
|
||||
const tasks: Array<{
|
||||
@@ -36,7 +38,11 @@ function runtime(
|
||||
if (result && !input.taskkillLeavesAlive) alive = false
|
||||
return result
|
||||
},
|
||||
tree: async () => input.tree ?? [],
|
||||
tree: async () => {
|
||||
if (input.treeCalls) input.treeCalls.count++
|
||||
if (input.treeError) throw new Error("process tree unavailable")
|
||||
return input.tree ?? []
|
||||
},
|
||||
alive: () => alive,
|
||||
signal: (pid, signal) => {
|
||||
signals.push({ pid, signal })
|
||||
@@ -83,6 +89,18 @@ describe("pty process-tree termination", () => {
|
||||
expect(input.sleeps).toEqual([200])
|
||||
})
|
||||
|
||||
test("continues when Windows process-tree inspection is unavailable", async () => {
|
||||
const treeCalls = { count: 0 }
|
||||
const input = runtime("win32", { treeError: true, treeCalls })
|
||||
const item = fake(42)
|
||||
|
||||
await KiloPtyTermination.terminate(item.proc, input.value)
|
||||
|
||||
expect(item.calls).toEqual([])
|
||||
expect(input.sleeps).toEqual([200])
|
||||
expect(treeCalls.count).toBe(0)
|
||||
})
|
||||
|
||||
test("signals POSIX process groups before escalating", async () => {
|
||||
const item = fake(42)
|
||||
const input = runtime("linux")
|
||||
|
||||
Reference in New Issue
Block a user