diff --git a/packages/backend/src/repoManager.ts b/packages/backend/src/repoManager.ts index 0c8a90c1..b84e3f94 100644 --- a/packages/backend/src/repoManager.ts +++ b/packages/backend/src/repoManager.ts @@ -6,7 +6,7 @@ import { GithubConnectionConfig, GitlabConnectionConfig, GiteaConnectionConfig } import { AppContext, Settings, RepoMetadata } from "./types.js"; import { getRepoPath, getTokenFromConfig, measure, getShardPrefix } from "./utils.js"; import { cloneRepository, fetchRepository } from "./git.js"; -import { existsSync, rmSync, readdirSync, rm } from 'fs'; +import { existsSync, readdirSync, promises } from 'fs'; import { indexGitRepository } from "./zoekt.js"; import os from 'os'; import { PromClient } from './promClient.js'; @@ -189,16 +189,12 @@ export class RepoManager implements IRepoManager { const repoPath = getRepoPath(repo, this.ctx); const metadata = repo.metadata as RepoMetadata; + // If the repo was already in the indexing state, this job was likely killed and picked up again. As a result, // to ensure the repo state is valid, we delete the repo if it exists so we get a fresh clone if (repoAlreadyInIndexingState && existsSync(repoPath)) { this.logger.info(`Deleting repo directory ${repoPath} during sync because it was already in the indexing state`); - await rm(repoPath, { recursive: true, force: true }, (err) => { - if (err) { - this.logger.error(`Failed to delete repo directory ${repoPath}: ${err}`); - throw err; - } - }); + await promises.rm(repoPath, { recursive: true, force: true }); } if (existsSync(repoPath)) { @@ -431,12 +427,7 @@ export class RepoManager implements IRepoManager { const repoPath = getRepoPath(repo, this.ctx); if (existsSync(repoPath)) { this.logger.info(`Deleting repo directory ${repoPath}`); - await rm(repoPath, { recursive: true, force: true }, (err) => { - if (err) { - this.logger.error(`Failed to delete repo directory ${repoPath}: ${err}`); - throw err; - } - }); + await promises.rm(repoPath, { recursive: true, force: true }); } // delete shards @@ -445,12 +436,7 @@ export class RepoManager implements IRepoManager { for (const file of files) { const filePath = `${this.ctx.indexPath}/${file}`; this.logger.info(`Deleting shard file ${filePath}`); - await rm(filePath, { force: true }, (err) => { - if (err) { - this.logger.error(`Failed to delete shard file ${filePath}: ${err}`); - throw err; - } - }); + await promises.rm(filePath, { force: true }); } } diff --git a/packages/web/public/502_page.html b/packages/web/public/502_page.html new file mode 100644 index 00000000..97d22b2a --- /dev/null +++ b/packages/web/public/502_page.html @@ -0,0 +1,142 @@ + + + + + + Sourcebot - Server Down + + + +
+
+ + +

Our servers are currently down. We're working to get everything back online as quickly as possible, please try again later.

+
+
+ + + + \ No newline at end of file diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index 6c8fb199..7bca2240 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -822,9 +822,9 @@ export const createOnboardingSubscription = async (domain: string) => const stripe = getStripe(); // @nocheckin - const test_clock = await stripe.testHelpers.testClocks.create({ + const test_clock = AUTH_URL !== "https://app.sourcebot.dev" ? await stripe.testHelpers.testClocks.create({ frozen_time: Math.floor(Date.now() / 1000) - }); + }) : null; // Use the existing customer if it exists, otherwise create a new one. const customerId = await (async () => { @@ -835,7 +835,7 @@ export const createOnboardingSubscription = async (domain: string) => const customer = await stripe.customers.create({ name: org.name, email: user.email ?? undefined, - test_clock: test_clock.id, + test_clock: test_clock?.id, description: `Created by ${user.email} on ${domain} (id: ${org.id})`, });