fix: settle relay git file list timeouts (#3731)

This commit is contained in:
Neil
2026-05-30 07:57:38 -07:00
committed by GitHub
parent 96b1417c48
commit 786fecde19
2 changed files with 34 additions and 0 deletions
+5
View File
@@ -108,8 +108,13 @@ export function listFilesWithGit(
resolve()
})
const timer = setTimeout(() => {
if (done) {
return
}
done = true
buf = ''
child.kill()
reject(new Error('git ls-files timed out'))
}, 10_000)
})
}
@@ -128,4 +128,33 @@ describe('relay quick open ignored file listing', () => {
await expect(promise).rejects.toThrow('git ls-files killed by SIGTERM')
})
it('git fallback rejects when a timed-out child does not emit close', async () => {
vi.useFakeTimers()
try {
const primaryProc = createMockProcess()
const ignoredProc = createMockProcess()
let callIndex = 0
spawnMock.mockImplementation(() => {
callIndex++
return callIndex === 1 ? primaryProc : ignoredProc
})
const promise = listFilesWithGit('/remote/root')
const outcomePromise = promise.then(
() => 'resolved',
(err: Error) => `rejected:${err.message}`
)
await vi.advanceTimersByTimeAsync(10_000)
const outcome = await Promise.race([outcomePromise, Promise.resolve('pending')])
expect(outcome).toContain('git ls-files timed out')
expect(primaryProc.kill).toHaveBeenCalled()
expect(ignoredProc.kill).toHaveBeenCalled()
} finally {
vi.useRealTimers()
}
})
})