From aa56ee64aabd34c58eb4c1b5cd35a292091c68e8 Mon Sep 17 00:00:00 2001 From: bkellam Date: Tue, 28 Oct 2025 17:22:17 -0700 Subject: [PATCH] Fix bug with multiple cleanup connections being scheduled --- packages/backend/src/repoIndexManager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/repoIndexManager.ts b/packages/backend/src/repoIndexManager.ts index 98258b0b..042ba8c7 100644 --- a/packages/backend/src/repoIndexManager.ts +++ b/packages/backend/src/repoIndexManager.ts @@ -149,7 +149,8 @@ export class RepoIndexManager { } private async scheduleCleanupJobs() { - const thresholdDate = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs); + const gcGracePeriodMs = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs); + const timeoutDate = new Date(Date.now() - this.settings.repoIndexTimeoutMs); const reposToCleanup = await this.db.repo.findMany({ where: { @@ -158,9 +159,8 @@ export class RepoIndexManager { }, OR: [ { indexedAt: null }, - { indexedAt: { lt: thresholdDate } }, + { indexedAt: { lt: gcGracePeriodMs } }, ], - // Don't schedule if there are active jobs that were created within the threshold date. NOT: { jobs: { some: { @@ -178,7 +178,7 @@ export class RepoIndexManager { }, { createdAt: { - gt: thresholdDate, + gt: timeoutDate, } } ]