mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 12:29:41 +02:00
Fix ccPair pages crashing
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { getCCPairSS } from "@/lib/ss/ccPair";
|
"use client";
|
||||||
|
|
||||||
import { CCPairFullInfo } from "./types";
|
import { CCPairFullInfo } from "./types";
|
||||||
import { getErrorMsg } from "@/lib/fetchUtils";
|
|
||||||
import { HealthCheckBanner } from "@/components/health/healthcheck";
|
import { HealthCheckBanner } from "@/components/health/healthcheck";
|
||||||
import { CCPairStatus } from "@/components/Status";
|
import { CCPairStatus } from "@/components/Status";
|
||||||
import { BackButton } from "@/components/BackButton";
|
import { BackButton } from "@/components/BackButton";
|
||||||
@@ -10,36 +10,42 @@ import { Text } from "@tremor/react";
|
|||||||
import { ConfigDisplay } from "./ConfigDisplay";
|
import { ConfigDisplay } from "./ConfigDisplay";
|
||||||
import { ModifyStatusButtonCluster } from "./ModifyStatusButtonCluster";
|
import { ModifyStatusButtonCluster } from "./ModifyStatusButtonCluster";
|
||||||
import { DeletionButton } from "./DeletionButton";
|
import { DeletionButton } from "./DeletionButton";
|
||||||
import { SSRAutoRefresh } from "@/components/SSRAutoRefresh";
|
|
||||||
import { ErrorCallout } from "@/components/ErrorCallout";
|
import { ErrorCallout } from "@/components/ErrorCallout";
|
||||||
import { ReIndexButton } from "./ReIndexButton";
|
import { ReIndexButton } from "./ReIndexButton";
|
||||||
import { isCurrentlyDeleting } from "@/lib/documentDeletion";
|
import { isCurrentlyDeleting } from "@/lib/documentDeletion";
|
||||||
import { ValidSources } from "@/lib/types";
|
import { ValidSources } from "@/lib/types";
|
||||||
|
import useSWR from "swr";
|
||||||
|
import { errorHandlingFetcher } from "@/lib/fetcher";
|
||||||
|
import { ThreeDotsLoader } from "@/components/Loading";
|
||||||
|
|
||||||
// since the uploaded files are cleaned up after some period of time
|
// since the uploaded files are cleaned up after some period of time
|
||||||
// re-indexing will not work for the file connector. Also, it would not
|
// re-indexing will not work for the file connector. Also, it would not
|
||||||
// make sense to re-index, since the files will not have changed.
|
// make sense to re-index, since the files will not have changed.
|
||||||
const CONNECTOR_TYPES_THAT_CANT_REINDEX: ValidSources[] = ["file"];
|
const CONNECTOR_TYPES_THAT_CANT_REINDEX: ValidSources[] = ["file"];
|
||||||
|
|
||||||
export default async function Page({
|
function Main({ ccPairId }: { ccPairId: number }) {
|
||||||
params,
|
const {
|
||||||
}: {
|
data: ccPair,
|
||||||
params: { ccPairId: string };
|
isLoading,
|
||||||
}) {
|
error,
|
||||||
const ccPairId = parseInt(params.ccPairId);
|
} = useSWR<CCPairFullInfo>(
|
||||||
|
`/api/manage/admin/cc-pair/${ccPairId}`,
|
||||||
|
errorHandlingFetcher
|
||||||
|
);
|
||||||
|
|
||||||
const ccPairResponse = await getCCPairSS(ccPairId);
|
if (isLoading) {
|
||||||
if (!ccPairResponse.ok) {
|
return <ThreeDotsLoader />;
|
||||||
const errorMsg = await getErrorMsg(ccPairResponse);
|
}
|
||||||
|
|
||||||
|
if (error || !ccPair) {
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto container">
|
<ErrorCallout
|
||||||
<BackButton />
|
errorTitle={`Failed to fetch info on Connector with ID ${ccPairId}`}
|
||||||
<ErrorCallout errorTitle={errorMsg} />
|
errorMsg={error.toString()}
|
||||||
</div>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccPair = (await ccPairResponse.json()) as CCPairFullInfo;
|
|
||||||
const lastIndexAttempt = ccPair.index_attempts[0];
|
const lastIndexAttempt = ccPair.index_attempts[0];
|
||||||
const isDeleting = isCurrentlyDeleting(ccPair.latest_deletion_attempt);
|
const isDeleting = isCurrentlyDeleting(ccPair.latest_deletion_attempt);
|
||||||
|
|
||||||
@@ -55,12 +61,6 @@ export default async function Page({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SSRAutoRefresh />
|
|
||||||
<div className="mx-auto container">
|
|
||||||
<div className="mb-4">
|
|
||||||
<HealthCheckBanner />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<BackButton />
|
<BackButton />
|
||||||
<div className="pb-1 flex mt-1">
|
<div className="pb-1 flex mt-1">
|
||||||
<h1 className="text-3xl text-emphasis font-bold">{ccPair.name}</h1>
|
<h1 className="text-3xl text-emphasis font-bold">{ccPair.name}</h1>
|
||||||
@@ -124,7 +124,20 @@ export default async function Page({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TODO: add document search*/}
|
{/* TODO: add document search*/}
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function Page({ params }: { params: { ccPairId: string } }) {
|
||||||
|
const ccPairId = parseInt(params.ccPairId);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mx-auto container">
|
||||||
|
<div className="mb-4">
|
||||||
|
<HealthCheckBanner />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Main ccPairId={ccPairId} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@@ -8,7 +8,6 @@ export function ErrorCallout({
|
|||||||
errorTitle?: string;
|
errorTitle?: string;
|
||||||
errorMsg?: string;
|
errorMsg?: string;
|
||||||
}) {
|
}) {
|
||||||
console.log(errorMsg);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Callout
|
<Callout
|
||||||
|
@@ -3,20 +3,22 @@
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export function SSRAutoRefresh({ refreshFreq = 5 }: { refreshFreq?: number }) {
|
// NOTE: this is causing crashes due to `ECONNRESET` and `UND_ERR_SOCKET`
|
||||||
// Helper which automatically refreshes a SSR page X seconds
|
// during the server-side fetch. Should not be used until this is resolved.
|
||||||
const router = useRouter();
|
// export function SSRAutoRefresh({ refreshFreq = 5 }: { refreshFreq?: number }) {
|
||||||
|
// // Helper which automatically refreshes a SSR page X seconds
|
||||||
|
// const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
// const interval = setInterval(() => {
|
||||||
router.refresh();
|
// router.refresh();
|
||||||
}, refreshFreq * 1000);
|
// }, refreshFreq * 1000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
// return () => clearInterval(interval);
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
return <></>;
|
// return <></>;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function InstantSSRAutoRefresh() {
|
export function InstantSSRAutoRefresh() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
Reference in New Issue
Block a user