mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 09:27:50 +00:00
misc: added timeout error prompt
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import { Knex } from "knex";
|
import { Knex, KnexTimeoutError } from "knex";
|
||||||
|
|
||||||
import { TDbClient } from "@app/db";
|
import { TDbClient } from "@app/db";
|
||||||
import { TableName } from "@app/db/schemas";
|
import { TableName } from "@app/db/schemas";
|
||||||
import { DatabaseError } from "@app/lib/errors";
|
import { BadRequestError, DatabaseError } from "@app/lib/errors";
|
||||||
import { ormify, selectAllTableCols } from "@app/lib/knex";
|
import { ormify, selectAllTableCols } from "@app/lib/knex";
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { QueueName } from "@app/queue";
|
import { QueueName } from "@app/queue";
|
||||||
@@ -110,6 +110,13 @@ export const auditLogDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
return docs;
|
return docs;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof KnexTimeoutError) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
error,
|
||||||
|
message: "Failed to fetch audit logs due to timeout. Add more search filters."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
throw new DatabaseError({ error });
|
throw new DatabaseError({ error });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { useInfiniteQuery, UseInfiniteQueryOptions, useQuery } from "@tanstack/react-query";
|
import { useInfiniteQuery, UseInfiniteQueryOptions, useQuery } from "@tanstack/react-query";
|
||||||
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { apiRequest } from "@app/config/request";
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
import { Actor, AuditLog, TGetAuditLogsFilter } from "./types";
|
import { Actor, AuditLog, TGetAuditLogsFilter } from "./types";
|
||||||
@@ -28,6 +30,7 @@ export const useGetAuditLogs = (
|
|||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
queryKey: auditLogKeys.getAuditLogs(projectId, filters),
|
queryKey: auditLogKeys.getAuditLogs(projectId, filters),
|
||||||
queryFn: async ({ pageParam }) => {
|
queryFn: async ({ pageParam }) => {
|
||||||
|
try {
|
||||||
const { data } = await apiRequest.get<{ auditLogs: AuditLog[] }>(
|
const { data } = await apiRequest.get<{ auditLogs: AuditLog[] }>(
|
||||||
"/api/v1/organization/audit-logs",
|
"/api/v1/organization/audit-logs",
|
||||||
{
|
{
|
||||||
@@ -49,6 +52,15 @@ export const useGetAuditLogs = (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
return data.auditLogs;
|
return data.auditLogs;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof AxiosError) {
|
||||||
|
createNotification({
|
||||||
|
type: "error",
|
||||||
|
text: error.response?.data.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getNextPageParam: (lastPage, pages) =>
|
getNextPageParam: (lastPage, pages) =>
|
||||||
lastPage.length !== 0 ? pages.length * filters.limit : undefined,
|
lastPage.length !== 0 ? pages.length * filters.limit : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user