fix: restart computer sidecar after errors (#3761)

This commit is contained in:
Neil 2026-05-30 11:30:02 -07:00 committed by GitHub
parent adb96dd450
commit 70c0f3dc0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -79,4 +79,28 @@ describe('computer sidecar client', () => {
await expect(secondCall).resolves.toEqual({ supports: { screenshots: true } })
})
it('starts a replacement sidecar after the active child errors', async () => {
const firstCall = callComputerSidecarCapabilities()
const firstRejection = expect(firstCall).rejects.toThrow('active sidecar failed')
const firstChild = children[0]!
firstChild.emit('error', new Error('active sidecar failed'))
await firstRejection
expect(firstChild.killed).toBe(true)
const secondCall = callComputerSidecarCapabilities()
void secondCall.catch(() => undefined)
expect(children).toHaveLength(2)
const secondChild = children[1]!
const secondRequest = secondChild.sent[0]!
secondChild.emit('message', {
id: secondRequest.id,
ok: true,
result: { supports: { screenshots: true } }
})
await expect(secondCall).resolves.toEqual({ supports: { screenshots: true } })
})
})

View File

@ -222,6 +222,10 @@ class ComputerSidecarProcess {
if (this.child !== child) {
return
}
// Why: an active process error makes the IPC sidecar unreliable; restart
// on the next call instead of reusing a broken helper.
this.child = null
child.kill('SIGTERM')
const wrapped = new RuntimeClientError('accessibility_error', error.message)
for (const [id, pending] of this.pending) {
clearTimeout(pending.timer)