The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Improve the script exiting
Rafi1e218ff8fff6
diff --git a/apps/web/lib/api/partners/search/providers/upstash-redis.ts b/apps/web/lib/api/partners/search/providers/upstash-redis.tsindex 0836292279..4cb925b003 100644--- a/apps/web/lib/api/partners/search/providers/upstash-redis.ts+++ b/apps/web/lib/api/partners/search/providers/upstash-redis.ts@@ -351,7 +351,9 @@ export async function createUpstashRedisPartnerSearchIndex({}validateIndexDescription(description, resolvedIndexName);- return index;+ // Hand back the description so callers can report on the index without+ // paying for a second describe() round trip.+ return { index, description };}export function createUpstashRedisPartnerSearchProvider({diff --git a/apps/web/scripts/dev/benchmark-partner-search.ts b/apps/web/scripts/dev/benchmark-partner-search.tsindex fc2533aa87..f81ea311e4 100644--- a/apps/web/scripts/dev/benchmark-partner-search.ts+++ b/apps/web/scripts/dev/benchmark-partner-search.ts@@ -575,7 +575,7 @@ async function main() {main().catch((error) => {console.error("Partner search benchmark failed:", error);- process.exit(1);+ process.exitCode = 1;}).finally(async () => {await prisma.$disconnect();diff --git a/apps/web/scripts/dev/debug-partner-search.ts b/apps/web/scripts/dev/debug-partner-search.tsindex 84574f26e1..495850fb10 100644--- a/apps/web/scripts/dev/debug-partner-search.ts+++ b/apps/web/scripts/dev/debug-partner-search.ts@@ -183,7 +183,7 @@ async function main() {main().catch((error) => {console.error("Partner search debug failed:", error);- process.exit(1);+ process.exitCode = 1;}).finally(async () => {await prisma.$disconnect();diff --git a/apps/web/scripts/dev/seed-100k-partners.ts b/apps/web/scripts/dev/seed-100k-partners.tsindex 7ce2a0c269..afdd665783 100644--- a/apps/web/scripts/dev/seed-100k-partners.ts+++ b/apps/web/scripts/dev/seed-100k-partners.ts@@ -509,7 +509,7 @@ async function main() {main().catch((e) => {console.error("❌ Error running partner seed script:", e);- process.exit(1);+ process.exitCode = 1;}).finally(async () => {await prisma.$disconnect();diff --git a/apps/web/scripts/partners/backfill-partner-search.ts b/apps/web/scripts/partners/backfill-partner-search.tsindex fb349c9ddf..5a06a9c216 100644--- a/apps/web/scripts/partners/backfill-partner-search.ts+++ b/apps/web/scripts/partners/backfill-partner-search.ts@@ -52,11 +52,14 @@ function parseArguments(args: string[]): BackfillArguments {return { programId, batchSize, after };}+let resumeAfter: string | undefined;+function reportProgress({batchSize,processed,lastDocumentId,}: PartnerSearchBackfillProgress) {+ resumeAfter = lastDocumentId;console.log(`Indexed ${processed.toLocaleString()} documents (${batchSize.toLocaleString()} in this batch), last document: ${lastDocumentId}`,);@@ -64,6 +67,7 @@ function reportProgress({async function main() {const { programId, batchSize, after } = parseArguments(process.argv.slice(2));+ resumeAfter = after;const providerName = getPartnerSearchProviderName();if (!providerName) {throw new Error("PARTNER_SEARCH_PROVIDER is not configured.");@@ -99,7 +103,18 @@ async function main() {main().catch((error) => {console.error("Partner search backfill failed:", error);- process.exit(1);++ if (resumeAfter) {+ const args = process.argv+ .slice(2)+ .filter((arg) => !arg.startsWith("--after="))+ .join(" ");+ console.error(+ `Documents up to ${resumeAfter} are indexed. Resume with:\n pnpm run script partners/backfill-partner-search ${args} --after=${resumeAfter}`,+ );+ }++ process.exitCode = 1;}).finally(async () => {await prisma.$disconnect();diff --git a/apps/web/scripts/partners/create-partner-search-index.ts b/apps/web/scripts/partners/create-partner-search-index.tsindex a98a8931b4..e351d21de4 100644--- a/apps/web/scripts/partners/create-partner-search-index.ts+++ b/apps/web/scripts/partners/create-partner-search-index.ts@@ -17,12 +17,9 @@ async function main() {return;}- const index = await createUpstashRedisPartnerSearchIndex();- const description = await index.describe();-- if (!description) {- throw new Error("Partner search index was not created.");- }+ // createUpstashRedisPartnerSearchIndex already described and validated the+ // index, so reuse that rather than describing it a second time.+ const { description } = await createUpstashRedisPartnerSearchIndex();console.log(`Partner search index is ready: ${description.name}`);console.log(`Document prefix: ${description.prefixes.join(", ")}`);@@ -30,5 +27,5 @@ async function main() {main().catch((error) => {console.error("Failed to create partner search index:", error);- process.exit(1);+ process.exitCode = 1;});diff --git a/apps/web/scripts/partners/delete-partner-search-index.ts b/apps/web/scripts/partners/delete-partner-search-index.tsindex 1793bc56d9..ad70d6cad7 100644--- a/apps/web/scripts/partners/delete-partner-search-index.ts+++ b/apps/web/scripts/partners/delete-partner-search-index.ts@@ -148,5 +148,5 @@ async function main() {main().catch((error) => {console.error("Failed to delete partner search index:", error);- process.exit(1);+ process.exitCode = 1;});