perf(ssh): batch cleanup lease retirement

This commit is contained in:
Jinwoo-H
2026-08-13 00:41:14 -04:00
parent f6d5df2840
commit 72ca0d4ced
+19 -3
View File
@@ -10901,7 +10901,7 @@ describe('Store', () => {
it('retires matching SSH cleanup leases in one persistence flush', async () => {
const store = await createStore()
for (const ptyId of ['cleanup-a', 'cleanup-b']) {
for (const ptyId of ['cleanup-a', 'cleanup-b', 'cleanup-replaced']) {
store.upsertSshRemotePtyLease({
targetId: 'ssh-1',
ptyId,
@@ -10910,15 +10910,31 @@ describe('Store', () => {
state: 'attached'
})
}
store.upsertSshRemotePtyLease({
targetId: 'ssh-1',
ptyId: 'cleanup-replaced',
cleanupPending: true,
cleanupExpectedIncarnationId: 'new-incarnation',
state: 'attached'
})
const flush = vi.spyOn(store as unknown as { flush(): void }, 'flush')
const retired = store.removeMatchingSshPtyCleanupLeases('ssh-1', [
{ ptyId: 'cleanup-a', cleanupExpectedIncarnationId: 'incarnation-cleanup-a' },
{ ptyId: 'cleanup-b', cleanupExpectedIncarnationId: 'incarnation-cleanup-b' }
{ ptyId: 'cleanup-b', cleanupExpectedIncarnationId: 'incarnation-cleanup-b' },
{
ptyId: 'cleanup-replaced',
cleanupExpectedIncarnationId: 'incarnation-cleanup-replaced'
}
])
expect(retired).toHaveLength(2)
expect(store.getSshRemotePtyLeases('ssh-1')).toEqual([])
expect(store.getSshRemotePtyLeases('ssh-1')).toEqual([
expect.objectContaining({
ptyId: 'cleanup-replaced',
cleanupExpectedIncarnationId: 'new-incarnation'
})
])
expect(flush).toHaveBeenCalledOnce()
})