fix(MULTIVERSION-0001): fix multi-version indexing — jobs never created or triggered for secondary versions
Two bugs prevented secondary versions from ever being indexed: 1. JobQueue.enqueue() and RepositoryService.createIndexingJob() deduplication only checked repository_id, so a queued default-branch job blocked all version-specific jobs for the same repo. Fix: include version_id in the WHERE clause so only exact (repository_id, version_id) pairs are deduped. 2. POST /api/v1/libs/:id/versions used repoService.createIndexingJob() which inserts a job record but never triggers queue processing. Fix: use queue.enqueue() (same fallback pattern as the libs endpoint) so setImmediate fires processNext() after the job is inserted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { RepositoryVersionMapper } from '$lib/server/mappers/repository-version.
|
||||
import { IndexingJobMapper } from '$lib/server/mappers/indexing-job.mapper.js';
|
||||
import { RepositoryService } from '$lib/server/services/repository.service';
|
||||
import { VersionService } from '$lib/server/services/version.service';
|
||||
import { getQueue } from '$lib/server/pipeline/startup';
|
||||
import { handleServiceError, NotFoundError, InvalidInputError } from '$lib/server/utils/validation';
|
||||
|
||||
function getServices() {
|
||||
@@ -78,7 +79,10 @@ export const POST: RequestHandler = async ({ params, request }) => {
|
||||
|
||||
let job: ReturnType<typeof IndexingJobMapper.toDto> | undefined;
|
||||
if (autoIndex) {
|
||||
const indexingJob = repoService.createIndexingJob(repositoryId, version.id);
|
||||
const queue = getQueue();
|
||||
const indexingJob = queue
|
||||
? queue.enqueue(repositoryId, version.id)
|
||||
: repoService.createIndexingJob(repositoryId, version.id);
|
||||
job = IndexingJobMapper.toDto(indexingJob);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user