From 99f49fa2efd3c1d7adbb84ef93c5eead199035da Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 23:32:22 +0000 Subject: [PATCH] Fix Supabase client configuration errors when USE_DB_AUTHENTICATION is false Co-Authored-By: hello@sideguide.dev --- apps/api/src/services/queue-worker.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.ts index 1c329c96e..690de7289 100644 --- a/apps/api/src/services/queue-worker.ts +++ b/apps/api/src/services/queue-worker.ts @@ -131,14 +131,18 @@ async function finishCrawlIfNeeded(job: Job & { id: string }, sc: StoredCrawl) { ), ); - const lastUrls: string[] = ( - ( - await supabase_service.rpc("diff_get_last_crawl_urls", { - i_team_id: job.data.team_id, - i_url: sc.originUrl!, - }) - ).data ?? [] - ).map((x) => x.url); + let lastUrls: string[] = []; + const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === "true"; + if (useDbAuthentication) { + lastUrls = ( + ( + await supabase_service.rpc("diff_get_last_crawl_urls", { + i_team_id: job.data.team_id, + i_url: sc.originUrl!, + }) + ).data ?? [] + ).map((x) => x.url); + } const lastUrlsSet = new Set(lastUrls); @@ -230,7 +234,8 @@ async function finishCrawlIfNeeded(job: Job & { id: string }, sc: StoredCrawl) { if ( visitedUrls.length > 0 && job.data.crawlerOptions !== null && - originUrl + originUrl && + process.env.USE_DB_AUTHENTICATION === "true" ) { // Queue the indexing job instead of doing it directly await getIndexQueue().add(