Skip to content

Commit 03999f0

Browse files
fix(worker): Use indexTimeoutMs setting for job timeout (#567)
1 parent 4ebe4e0 commit 03999f0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616
- Fixed "dubious ownership" errors when cloning / fetching repos. [#553](https://github.com/sourcebot-dev/sourcebot/pull/553)
1717
- Fixed issue with Ask Sourcebot tutorial re-appearing after restarting the browser. [#563](https://github.com/sourcebot-dev/sourcebot/pull/563)
18+
- Fixed `repoIndexTimeoutMs` not being used for index job timeouts. [#567](https://github.com/sourcebot-dev/sourcebot/pull/567)
1819

1920
### Changed
2021
- Improved search performance for unbounded search queries. [#555](https://github.com/sourcebot-dev/sourcebot/pull/555)

packages/backend/src/repoIndexManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ type JobPayload = {
2323
repoName: string;
2424
};
2525

26-
const JOB_TIMEOUT_MS = 1000 * 60 * 60 * 6; // 6 hour indexing timeout
27-
2826
/**
2927
* Manages the lifecycle of repository data on disk, including git working copies
3028
* and search index shards. Handles both indexing operations (cloning/fetching repos
@@ -49,7 +47,7 @@ export class RepoIndexManager {
4947
this.queue = new Queue<JobPayload>({
5048
redis,
5149
namespace: 'repo-index-queue',
52-
jobTimeoutMs: JOB_TIMEOUT_MS,
50+
jobTimeoutMs: this.settings.repoIndexTimeoutMs,
5351
maxAttempts: 3,
5452
logger: env.DEBUG_ENABLE_GROUPMQ_LOGGING === 'true',
5553
});
@@ -82,6 +80,8 @@ export class RepoIndexManager {
8280

8381
private async scheduleIndexJobs() {
8482
const thresholdDate = new Date(Date.now() - this.settings.reindexIntervalMs);
83+
const timeoutDate = new Date(Date.now() - this.settings.repoIndexTimeoutMs);
84+
8585
const reposToIndex = await this.db.repo.findMany({
8686
where: {
8787
AND: [
@@ -115,7 +115,7 @@ export class RepoIndexManager {
115115
},
116116
{
117117
createdAt: {
118-
gt: thresholdDate,
118+
gt: timeoutDate,
119119
}
120120
}
121121
]
@@ -124,7 +124,7 @@ export class RepoIndexManager {
124124
{
125125
AND: [
126126
{ status: RepoIndexingJobStatus.FAILED },
127-
{ completedAt: { gt: thresholdDate } },
127+
{ completedAt: { gt: timeoutDate } },
128128
]
129129
}
130130
]

0 commit comments

Comments
 (0)