Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Hoist routedToFirebill above the try so the catch's refund decision sees it

Rakshith Ramprakash685e82dba81d
diff --git a/apps/api/src/services/worker/scrape-worker.ts b/apps/api/src/services/worker/scrape-worker.ts
index 0ac252a65..04dd190b4 100644
--- a/apps/api/src/services/worker/scrape-worker.ts
+++ b/apps/api/src/services/worker/scrape-worker.ts
@@ -170,8 +170,10 @@ async function billScrapeJob(
job.data.team_id !== config.BACKGROUND_INDEX_TEAM_ID! &&
config.USE_DB_AUTHENTICATION
) {
+ // Resolved outside the try so the catch's refund decision can see it.
+ let routedToFirebill = false;
try {
- const routedToFirebill = await autumnService.isRoutedThroughFirebill(
+ routedToFirebill = await autumnService.isRoutedThroughFirebill(
job.data.team_id,
);
trackedInRequest = await autumnService.trackCredits({