mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix(memory): bound local Git capability cache
This commit is contained in:
@@ -35,6 +35,19 @@ describe('Git capability execution-host state', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('bounds local capability entries during WSL distro churn', () => {
|
||||
const first = getLocalGitCapabilityCache({ wslDistro: 'first-distro' })
|
||||
first.rememberUnsupported('worktree-list-path-format')
|
||||
for (let index = 0; index < 132; index += 1) {
|
||||
getLocalGitCapabilityCache({ wslDistro: `distro-${index}` })
|
||||
}
|
||||
expect(
|
||||
getLocalGitCapabilityCache({ wslDistro: 'first-distro' }).shouldTry(
|
||||
'worktree-list-path-format'
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('shares one SSH provider lifetime without leaking into a replacement provider', () => {
|
||||
const provider = createProviderIdentity()
|
||||
const replacementProvider = createProviderIdentity()
|
||||
|
||||
@@ -13,6 +13,7 @@ type LocalGitCapabilityTarget = {
|
||||
}
|
||||
|
||||
const localCapabilitiesByExecutionHost = new Map<string, GitCapabilityCache>()
|
||||
const MAX_LOCAL_GIT_CAPABILITY_HOSTS = 128
|
||||
// Why: reconnecting creates a new provider, while concurrent IPC/runtime users
|
||||
// of one SSH connection must share the same remote Git capability results.
|
||||
let sshCapabilitiesByProvider = new WeakMap<SshGitProvider, GitCapabilityCache>()
|
||||
@@ -30,7 +31,15 @@ export function getLocalGitCapabilityCache(
|
||||
let cache = localCapabilitiesByExecutionHost.get(executionHost)
|
||||
if (!cache) {
|
||||
cache = new GitCapabilityCache()
|
||||
localCapabilitiesByExecutionHost.set(executionHost, cache)
|
||||
}
|
||||
localCapabilitiesByExecutionHost.delete(executionHost)
|
||||
localCapabilitiesByExecutionHost.set(executionHost, cache)
|
||||
while (localCapabilitiesByExecutionHost.size > MAX_LOCAL_GIT_CAPABILITY_HOSTS) {
|
||||
const oldest = localCapabilitiesByExecutionHost.keys().next().value
|
||||
if (oldest === undefined) {
|
||||
break
|
||||
}
|
||||
localCapabilitiesByExecutionHost.delete(oldest)
|
||||
}
|
||||
return cache
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user