update error handling

This commit is contained in:
Nate Kelley 2025-10-02 11:46:33 -06:00
parent 0b3e01106c
commit 619881b051
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 278 additions and 263 deletions

View File

@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
"extends": ["../../biome2.json"],
"files": {
"includes": ["!**/routeTree.gen.ts", "!.vercel", "!.nitro", "!.storybook"]

View File

@ -39,7 +39,7 @@
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@electric-sql/client": "catalog:",
"@electric-sql/react": "^1.0.10",
"@electric-sql/react": "^1.0.12",
"@emoji-mart/data": "^1.2.1",
"@faker-js/faker": "^10.0.0",
"@monaco-editor/react": "^4.7.0",
@ -102,7 +102,7 @@
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/query-db-collection": "0.2.24",
"@tanstack/react-db": "0.1.25",
"@tanstack/react-devtools": "^0.7.0",
"@tanstack/react-devtools": "^0.7.1",
"@tanstack/react-form": "^1.23.5",
"@tanstack/react-query": "^5.90.2",
"@tanstack/react-query-devtools": "^5.90.2",
@ -117,7 +117,7 @@
"@tanstack/react-virtual": "^3.13.12",
"@tanstack/router-plugin": "^1.131.50",
"@tanstack/store": "^0.7.7",
"@testing-library/jest-dom": "^6.9.0",
"@testing-library/jest-dom": "^6.9.1",
"@tiptap/core": "^3.6.2",
"@tiptap/extension-document": "^3.6.2",
"@tiptap/extension-mention": "^3.6.2",
@ -158,7 +158,7 @@
"mutative": "^1.3.0",
"platejs": "49.2.21",
"pluralize": "^8.0.0",
"posthog-js": "^1.268.9",
"posthog-js": "^1.269.1",
"qs": "^6.14.0",
"react": "catalog:",
"react-colorful": "^5.6.1",
@ -175,7 +175,7 @@
"react-speech-recognition": "^4.0.1",
"react-textarea-autosize": "^8.5.9",
"remark-gfm": "^4.0.1",
"scheduler": "^0.26.0",
"scheduler": "^0.27.0",
"shiki": "^3.13.0",
"sonner": "^2.0.7",
"tailwind-merge": "^3.3.1",
@ -187,18 +187,18 @@
"use-file-picker": "^2.1.4",
"utility-types": "^3.11.0",
"uuid": "catalog:",
"virtua": "^0.43.6",
"virtua": "^0.44.0",
"vite-tsconfig-paths": "^5.1.4",
"vitest-browser-react": "^1.0.1",
"zod": "catalog:"
},
"devDependencies": {
"@biomejs/biome": "2.2.4",
"@biomejs/biome": "2.2.5",
"@chromatic-com/storybook": "^4.1.1",
"@storybook/addon-a11y": "^9.1.9",
"@storybook/addon-docs": "^9.1.9",
"@storybook/addon-vitest": "^9.1.9",
"@storybook/react-vite": "^9.1.9",
"@storybook/addon-a11y": "^9.1.10",
"@storybook/addon-docs": "^9.1.10",
"@storybook/addon-vitest": "^9.1.10",
"@storybook/react-vite": "^9.1.10",
"@tanstack/devtools-event-client": "^0.3.2",
"@tanstack/router-cli": "^1.131.50",
"@testing-library/dom": "^10.4.1",

View File

@ -74,6 +74,7 @@ export const useGetMetric = <TData = BusterMetric>(
params?: Omit<UseQueryOptions<BusterMetric, ApiError, TData>, 'queryKey' | 'queryFn'>
) => {
const queryClient = useQueryClient();
const query = metricsQueryKeys.metricsGetMetric(id || '', 'LATEST');
const password = useProtectedAssetPassword(id || '');
const { selectedVersionNumber, latestVersionNumber } = useGetMetricVersionNumber(
@ -82,7 +83,7 @@ export const useGetMetric = <TData = BusterMetric>(
);
const { isFetched: isFetchedInitial, isError: isErrorInitial } = useQuery({
...metricsQueryKeys.metricsGetMetric(id || '', 'LATEST'),
...query,
queryFn: () => {
return getMetricQueryFn({ id, version: 'LATEST', queryClient, password });
},
@ -125,19 +126,21 @@ export const prefetchGetMetric = async (
params: Parameters<typeof getMetric>[0]
): Promise<BusterMetric | undefined> => {
const { id, version_number } = params;
const queryKey = metricsQueryKeys.metricsGetMetric(id, version_number || 'LATEST')?.queryKey;
const query = metricsQueryKeys.metricsGetMetric(id, version_number || 'LATEST');
const queryKey = query?.queryKey;
const existingData = queryClient.getQueryData(queryKey);
if (!existingData && id) {
await queryClient.prefetchQuery({
...metricsQueryKeys.metricsGetMetric(id, version_number || 'LATEST'),
queryFn: () =>
getMetricQueryFn({
...query,
queryFn: () => {
return getMetricQueryFn({
id,
version: params.version_number,
queryClient,
password: undefined,
}),
});
},
retry: silenceAssetErrors,
});
}

View File

@ -21,10 +21,10 @@ export const getAssetAccess = (
error: ApiError | null,
isFetched: boolean,
selectedQuery: QueryKey,
_hasData: boolean
hasData: boolean
): AssetAccess => {
if (error) {
console.error('Error in getAssetAccess', error, isFetched, selectedQuery);
console.error('Error in getAssetAccess', error, isFetched, selectedQuery, hasData);
}
// 418 is password required
@ -66,7 +66,7 @@ export const getAssetAccess = (
passwordRequired: false,
isPublic: false,
isDeleted: false,
isFetched: isFetched,
isFetched,
};
}
@ -95,8 +95,6 @@ export const useGetAssetPasswordConfig = (
queryKey: selectedQuery.queryKey,
enabled: true,
select: (v: unknown) => !!v,
retry: false,
initialData: false,
});
return getAssetAccess(error, isFetched, selectedQuery.queryKey, !!data);

File diff suppressed because it is too large Load Diff