diff --git a/apps/frontend/app/artifacts/[source]/[...name]/page.tsx b/apps/frontend/app/artifacts/[source]/[...name]/page.tsx
index f2d723720..a45434bd9 100644
--- a/apps/frontend/app/artifacts/[source]/[...name]/page.tsx
+++ b/apps/frontend/app/artifacts/[source]/[...name]/page.tsx
@@ -1,4 +1,4 @@
-import { notFound } from "next/navigation";
+import { notFound, redirect } from "next/navigation";
import { cache } from "react";
import { PlasmicComponent } from "@plasmicapp/loader-nextjs";
import { PLASMIC } from "../../../../plasmic-init";
@@ -10,6 +10,7 @@ import {
} from "../../../../lib/clickhouse/cached-queries";
import { logger } from "../../../../lib/logger";
+const RETRY_URL = "/retry";
const PLASMIC_COMPONENT = "ArtifactPage";
//export const dynamic = STATIC_EXPORT ? "force-static" : "force-dynamic";
export const dynamic = "force-dynamic";
@@ -70,51 +71,56 @@ export default async function ArtifactPage(props: ArtifactPageProps) {
const [namespace, name] =
params.name.length > 1 ? params.name : [undefined, params.name[0]];
- // Get artifact metadata from the database
- const artifactArray = await cachedGetArtifactByName({
- artifactSource: source,
- artifactNamespace: namespace,
- artifactName: name,
- });
- if (!Array.isArray(artifactArray) || artifactArray.length < 1) {
- logger.warn(
- `Cannot find artifact (source=${source}, namespace=${namespace}, name=${name})`,
- );
- notFound();
- }
- const artifact = artifactArray[0];
- const artifactId = artifact.artifact_id;
+ try {
+ // Get artifact metadata from the database
+ const artifactArray = await cachedGetArtifactByName({
+ artifactSource: source,
+ artifactNamespace: namespace,
+ artifactName: name,
+ });
+ if (!Array.isArray(artifactArray) || artifactArray.length < 1) {
+ logger.warn(
+ `Cannot find artifact (source=${source}, namespace=${namespace}, name=${name})`,
+ );
+ notFound();
+ }
+ const artifact = artifactArray[0];
+ const artifactId = artifact.artifact_id;
- const data = await Promise.all([
- cachedGetAllEventTypes(),
- cachedGetCodeMetricsByArtifactIds({
- artifactIds: [artifactId],
- }),
- ]);
- const eventTypes = data[0];
- const codeMetrics = data[1];
+ const data = await Promise.all([
+ cachedGetAllEventTypes(),
+ cachedGetCodeMetricsByArtifactIds({
+ artifactIds: [artifactId],
+ }),
+ ]);
+ const eventTypes = data[0];
+ const codeMetrics = data[1];
- //console.log(artifact);
- const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
- if (!plasmicData) {
- logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
- notFound();
- }
- const compMeta = plasmicData.entryCompMetas[0];
+ //console.log(artifact);
+ const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
+ if (!plasmicData) {
+ logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
+ notFound();
+ }
+ const compMeta = plasmicData.entryCompMetas[0];
- return (
-
-
-
- );
+ return (
+
+
+
+ );
+ } catch (_e) {
+ // Most likely caused by database timing out
+ redirect(RETRY_URL);
+ }
}
diff --git a/apps/frontend/app/collections/[...name]/page.tsx b/apps/frontend/app/collections/[...name]/page.tsx
index 0fe28ba87..b2fbc46b7 100644
--- a/apps/frontend/app/collections/[...name]/page.tsx
+++ b/apps/frontend/app/collections/[...name]/page.tsx
@@ -1,4 +1,4 @@
-import { notFound } from "next/navigation";
+import { notFound, redirect } from "next/navigation";
import { cache } from "react";
import { PlasmicComponent } from "@plasmicapp/loader-nextjs";
import { PLASMIC } from "../../../plasmic-init";
@@ -14,6 +14,7 @@ import { catchallPathToString } from "../../../lib/paths";
const COLLECTION_SOURCE = "OSS_DIRECTORY";
const COLLECTION_NAMESPACE = "oso";
+const RETRY_URL = "/retry";
const PLASMIC_COMPONENT = "CollectionPage";
//export const dynamic = STATIC_EXPORT ? "force-static" : "force-dynamic";
//export const dynamic = "force-static";
@@ -59,67 +60,72 @@ export default async function CollectionPage(props: CollectionPageProps) {
notFound();
}
- // Get project metadata from the database
- const name = catchallPathToString(params.name);
- const data1 = await Promise.all([
- await cachedGetCollectionByName({
- collectionSource: COLLECTION_SOURCE,
- collectionNamespace: COLLECTION_NAMESPACE,
- collectionName: name,
- }),
- await cachedGetProjectIdsByCollectionName({
- collectionSource: COLLECTION_SOURCE,
- collectionNamespace: COLLECTION_NAMESPACE,
- collectionName: name,
- }),
- ]);
- const collectionArray = data1[0];
- const projectIdArray = data1[1];
- if (
- !Array.isArray(collectionArray) ||
- collectionArray.length < 1 ||
- !Array.isArray(projectIdArray)
- ) {
- logger.warn(`Cannot find collection (name=${name})`);
- notFound();
- }
- const collection = collectionArray[0];
- //console.log("project", project);
+ try {
+ // Get project metadata from the database
+ const name = catchallPathToString(params.name);
+ const data1 = await Promise.all([
+ await cachedGetCollectionByName({
+ collectionSource: COLLECTION_SOURCE,
+ collectionNamespace: COLLECTION_NAMESPACE,
+ collectionName: name,
+ }),
+ await cachedGetProjectIdsByCollectionName({
+ collectionSource: COLLECTION_SOURCE,
+ collectionNamespace: COLLECTION_NAMESPACE,
+ collectionName: name,
+ }),
+ ]);
+ const collectionArray = data1[0];
+ const projectIdArray = data1[1];
+ if (
+ !Array.isArray(collectionArray) ||
+ collectionArray.length < 1 ||
+ !Array.isArray(projectIdArray)
+ ) {
+ logger.warn(`Cannot find collection (name=${name})`);
+ notFound();
+ }
+ const collection = collectionArray[0];
+ //console.log("project", project);
- // Parallelize getting things related to the project
- const projectIds = projectIdArray.map((x) => x.project_id);
- const data2 = await Promise.all([
- cachedGetCodeMetricsByProjectIds({
- projectIds,
- }),
- cachedGetOnchainMetricsByProjectIds({
- projectIds,
- }),
- ]);
- const codeMetrics = data2[0];
- const onchainMetrics = data2[1];
+ // Parallelize getting things related to the project
+ const projectIds = projectIdArray.map((x) => x.project_id);
+ const data2 = await Promise.all([
+ cachedGetCodeMetricsByProjectIds({
+ projectIds,
+ }),
+ cachedGetOnchainMetricsByProjectIds({
+ projectIds,
+ }),
+ ]);
+ const codeMetrics = data2[0];
+ const onchainMetrics = data2[1];
- // Get Plasmic component
- const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
- if (!plasmicData) {
- logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
- notFound();
- }
- const compMeta = plasmicData.entryCompMetas[0];
+ // Get Plasmic component
+ const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
+ if (!plasmicData) {
+ logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
+ notFound();
+ }
+ const compMeta = plasmicData.entryCompMetas[0];
- return (
-
-
-
- );
+ return (
+
+
+
+ );
+ } catch (_e) {
+ // Most likely caused by database timing out
+ redirect(RETRY_URL);
+ }
}
diff --git a/apps/frontend/app/projects/[...name]/page.tsx b/apps/frontend/app/projects/[...name]/page.tsx
index 78de72dd3..bf07dd84f 100644
--- a/apps/frontend/app/projects/[...name]/page.tsx
+++ b/apps/frontend/app/projects/[...name]/page.tsx
@@ -1,4 +1,4 @@
-import { notFound } from "next/navigation";
+import { notFound, redirect } from "next/navigation";
import { cache } from "react";
import { PlasmicComponent } from "@plasmicapp/loader-nextjs";
import { PLASMIC } from "../../../plasmic-init";
@@ -12,6 +12,7 @@ import {
import { logger } from "../../../lib/logger";
import { catchallPathToString } from "../../../lib/paths";
+const RETRY_URL = "/retry";
const PLASMIC_COMPONENT = "ProjectPage";
//export const dynamic = STATIC_EXPORT ? "force-static" : "force-dynamic";
//export const dynamic = "force-static";
@@ -57,55 +58,60 @@ export default async function ProjectPage(props: ProjectPageProps) {
notFound();
}
- // Get project metadata from the database
- const name = catchallPathToString(params.name);
- const projectArray = await cachedGetProjectByName({
- projectName: name,
- });
- if (!Array.isArray(projectArray) || projectArray.length < 1) {
- logger.warn(`Cannot find project (name=${name})`);
- notFound();
- }
- const project = projectArray[0];
- const projectId = project.project_id;
- //console.log("project", project);
+ try {
+ // Get project metadata from the database
+ const name = catchallPathToString(params.name);
+ const projectArray = await cachedGetProjectByName({
+ projectName: name,
+ });
+ if (!Array.isArray(projectArray) || projectArray.length < 1) {
+ logger.warn(`Cannot find project (name=${name})`);
+ notFound();
+ }
+ const project = projectArray[0];
+ const projectId = project.project_id;
+ //console.log("project", project);
- // Parallelize getting things related to the project
- const data = await Promise.all([
- cachedGetAllEventTypes(),
- cachedGetCodeMetricsByProjectIds({
- projectIds: [projectId],
- }),
- cachedGetOnchainMetricsByProjectIds({
- projectIds: [projectId],
- }),
- ]);
- const eventTypes = data[0];
- const codeMetrics = data[1];
- const onchainMetrics = data[2];
+ // Parallelize getting things related to the project
+ const data = await Promise.all([
+ cachedGetAllEventTypes(),
+ cachedGetCodeMetricsByProjectIds({
+ projectIds: [projectId],
+ }),
+ cachedGetOnchainMetricsByProjectIds({
+ projectIds: [projectId],
+ }),
+ ]);
+ const eventTypes = data[0];
+ const codeMetrics = data[1];
+ const onchainMetrics = data[2];
- // Get Plasmic component
- const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
- if (!plasmicData) {
- logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
- notFound();
- }
- const compMeta = plasmicData.entryCompMetas[0];
+ // Get Plasmic component
+ const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT);
+ if (!plasmicData) {
+ logger.warn(`Unable to get componentName=${PLASMIC_COMPONENT}`);
+ notFound();
+ }
+ const compMeta = plasmicData.entryCompMetas[0];
- return (
-
-
-
- );
+ return (
+
+
+
+ );
+ } catch (_e) {
+ // Most likely caused by database timing out
+ redirect(RETRY_URL);
+ }
}