Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
abort jira work after 20 sec limit
Andrey30541979c52d
diff --git a/backend/src/services/app-connection/jira/jira-connection-fns.ts b/backend/src/services/app-connection/jira/jira-connection-fns.tsindex 95f1d24371..04173287dc 100644--- a/backend/src/services/app-connection/jira/jira-connection-fns.ts+++ b/backend/src/services/app-connection/jira/jira-connection-fns.ts@@ -26,6 +26,7 @@ const JIRA_MAX_ERROR_DETAIL_LENGTH = 300;export type TJiraGatewayDeps = {gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "runWithPoolFailover">;+ signal?: AbortSignal;};export type TJiraRequestConfig = DiscriminativePick<@@ -78,7 +79,7 @@ const getJiraTlsOptions = (config: TJiraRequestConfig) => {export const jiraRequest = async <T>(config: TJiraRequestConfig,{ path, params, headers: extraHeaders }: TJiraRequest,- { gatewayV2Service, gatewayPoolService }: TJiraGatewayDeps = {}+ { gatewayV2Service, gatewayPoolService, signal }: TJiraGatewayDeps = {}): Promise<T> => {const { gatewayId: directGatewayId, gatewayPoolId } = config;@@ -96,7 +97,8 @@ export const jiraRequest = async <T>(method: "GET",params,timeout: JIRA_REQUEST_TIMEOUT_MS,- maxContentLength: JIRA_MAX_RESPONSE_BYTES+ maxContentLength: JIRA_MAX_RESPONSE_BYTES,+ signal};const requestThroughGateway = async (gatewayId: string) => {diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-service.tsindex de7eebb4d6..9fe83ef265 100644--- a/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts@@ -63,13 +63,22 @@ type TAutoApprovalServiceFactoryDep = {export type TAutoApprovalServiceFactory = ReturnType<typeof autoApprovalServiceFactory>;-const withTimeout = async <T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> => {+// Aborts the work on timeout, so a slow service isn't still being called after the result stopped mattering+const withTimeout = async <T>(+ run: (signal: AbortSignal) => Promise<T>,+ timeoutMs: number,+ message: string+): Promise<T> => {+ const controller = new AbortController();let timer: NodeJS.Timeout | undefined;try {return await Promise.race([- promise,+ run(controller.signal),new Promise<never>((_, reject) => {- timer = setTimeout(() => reject(new BadRequestError({ message })), timeoutMs);+ timer = setTimeout(() => {+ reject(new BadRequestError({ message }));+ controller.abort();+ }, timeoutMs);})]);} finally {@@ -397,7 +406,11 @@ export const autoApprovalServiceFactory = ({try {const facts: unknown = await withTimeout(- definition.resolve(connection, parsedInput?.id ?? null, ctx, [...target.constraintIds], providerDeps),+ (signal) =>+ definition.resolve(connection, parsedInput?.id ?? null, ctx, [...target.constraintIds], {+ ...providerDeps,+ signal+ }),RESOLVE_TIMEOUT_MS,`${getAppName(connection.app)} didn't respond in time`);diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-types.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-types.tsindex df8f742194..2f21f0b8bf 100644--- a/backend/src/services/approval-policy/auto-approval/auto-approval-types.ts+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-types.ts@@ -16,6 +16,7 @@ export type TAutoApprovalOption = { value: string; label: string };export type TAutoApprovalProviderDeps = {gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;gatewayPoolService: Pick<TGatewayPoolServiceFactory, "runWithPoolFailover">;+ signal?: AbortSignal;};// Infisical runs this check itself, against its own approved requests, on every record a requester links