From 1b6fd015753f214e1187496db0fa625624f5440e Mon Sep 17 00:00:00 2001 From: stacksmash76 <98354295+stacksmash76@users.noreply.github.com> Date: Thu, 10 Nov 2022 12:32:57 +0100 Subject: [PATCH] fix(web): infinitely retry queries, remove `ago` from age cells (#528) - infinitely retry web queries so we avoid the "failed to fetch" error when the web server is unavailable - remove the "ago" suffix from age cells (closes #497) --- web/src/App.tsx | 8 +++++++- web/src/components/data-table/Cells.tsx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index 5244213..92bae96 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -10,7 +10,13 @@ import Toast from "./components/notifications/Toast"; export const queryClient = new QueryClient({ defaultOptions: { - queries: { useErrorBoundary: true }, + queries: { + // The retries will have exponential delay. + // See https://tanstack.com/query/v4/docs/guides/query-retries#retry-delay + // delay = Math.min(1000 * 2 ** attemptIndex, 30000) + retry: true, + useErrorBoundary: true + }, mutations: { onError: (error) => { // Use a format string to convert the error object to a proper string without much hassle. diff --git a/web/src/components/data-table/Cells.tsx b/web/src/components/data-table/Cells.tsx index 08c2b7c..dc331c6 100644 --- a/web/src/components/data-table/Cells.tsx +++ b/web/src/components/data-table/Cells.tsx @@ -12,7 +12,7 @@ interface CellProps { export const AgeCell = ({ value }: CellProps) => (
- {formatDistanceToNowStrict(new Date(value), { addSuffix: true })} + {formatDistanceToNowStrict(new Date(value), { addSuffix: false })}
);