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
remove stuck timeout env var
Matheus Nogueira83bbdab56417
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex 821c643418..193da6f72c 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -121,30 +121,11 @@ export const secretScanningTimeoutsSchema = z.object({description: "Wall-clock ceiling for a single `git clone` invocation before its process group is killed",defaultValue: "10m",legacyMsEnvVar: "SECRET_SCANNING_CLONE_TIMEOUT_MS"- }),- SECRET_SCANNING_STUCK_SCAN_TIMEOUT: zodTimeoutMs({- envVar: "SECRET_SCANNING_STUCK_SCAN_TIMEOUT",- description:- "A scan left in the `scanning` state for longer than this is marked failed by the reaper. Must exceed clone + scan timeouts combined.",- defaultValue: "1h",- legacyMsEnvVar: "SECRET_SCANNING_STUCK_SCAN_TIMEOUT_MS"})});-export const validateSecretScanningTimeouts = (- data: z.infer<typeof secretScanningTimeoutsSchema>,- ctx: z.RefinementCtx-) => {- const scanBudgetMs =- data.SECRET_SCANNING_CLONE_TIMEOUT + data.SECRET_SCANNING_SCAN_TIMEOUT + SECRET_SCANNING_SCAN_OVERHEAD;- if (data.SECRET_SCANNING_STUCK_SCAN_TIMEOUT <= scanBudgetMs) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- path: ["SECRET_SCANNING_STUCK_SCAN_TIMEOUT"],- message: `SECRET_SCANNING_STUCK_SCAN_TIMEOUT (${data.SECRET_SCANNING_STUCK_SCAN_TIMEOUT}ms) must exceed SECRET_SCANNING_CLONE_TIMEOUT + SECRET_SCANNING_SCAN_TIMEOUT plus ${SECRET_SCANNING_SCAN_OVERHEAD}ms of measurement and bookkeeping (${scanBudgetMs}ms), otherwise healthy in-flight scans are reaped as stuck.`- });- }-};+export const getSecretScanningStuckScanTimeout = (data: z.infer<typeof secretScanningTimeoutsSchema>) =>+ data.SECRET_SCANNING_CLONE_TIMEOUT + data.SECRET_SCANNING_SCAN_TIMEOUT + SECRET_SCANNING_SCAN_OVERHEAD;const databaseReadReplicaSchema = z.object({@@ -689,11 +670,10 @@ const envSchema = z});}});-- validateSecretScanningTimeouts(data, ctx);}).transform((data) => ({...data,+ SECRET_SCANNING_STUCK_SCAN_TIMEOUT: getSecretScanningStuckScanTimeout(data),SALT_ROUNDS: data.SALT_ROUNDS || data.BCRYPT_SALT_ROUND || 12,DISABLE_POSTGRES_AUDIT_LOG_STORAGE:data.DISABLE_POSTGRES_AUDIT_LOG_STORAGE ?? data.DISABLE_AUDIT_LOG_STORAGE ?? false,diff --git a/backend/src/lib/config/secret-scanning-timeouts.test.ts b/backend/src/lib/config/secret-scanning-timeouts.test.tsindex 539cf760a3..dfdd80b7f0 100644--- a/backend/src/lib/config/secret-scanning-timeouts.test.ts+++ b/backend/src/lib/config/secret-scanning-timeouts.test.ts@@ -1,10 +1,8 @@import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";-import { secretScanningTimeoutsSchema, validateSecretScanningTimeouts } from "./env";+import { getSecretScanningStuckScanTimeout, secretScanningTimeoutsSchema } from "./env";-const schema = secretScanningTimeoutsSchema.superRefine(validateSecretScanningTimeouts);--const parse = (env: Record<string, string>) => schema.safeParse(env);+const parse = (env: Record<string, string>) => secretScanningTimeoutsSchema.safeParse(env);const issuesFor = (result: ReturnType<typeof parse>, key: string) =>result.success ? [] : result.error.issues.filter((issue) => issue.path[0] === key).map((issue) => issue.message);@@ -14,15 +12,14 @@ afterEach(() => {});describe("secret scanning timeouts", () => {- test("defaults to ten minute clone and scan timeouts and a one hour stuck threshold", () => {+ test("defaults to ten minute clone and scan timeouts", () => {const result = parse({});expect(result.success).toBe(true);if (result.success) {expect(result.data).toEqual({SECRET_SCANNING_CLONE_TIMEOUT: 10 * 60 * 1000,- SECRET_SCANNING_SCAN_TIMEOUT: 10 * 60 * 1000,- SECRET_SCANNING_STUCK_SCAN_TIMEOUT: 60 * 60 * 1000+ SECRET_SCANNING_SCAN_TIMEOUT: 10 * 60 * 1000});}});@@ -33,7 +30,7 @@ describe("secret scanning timeouts", () => {["15m", 15 * 60 * 1000],["2h", 2 * 60 * 60 * 1000]])("reads %s as milliseconds", (value, expected) => {- const result = parse({ SECRET_SCANNING_SCAN_TIMEOUT: value, SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "6h" });+ const result = parse({ SECRET_SCANNING_SCAN_TIMEOUT: value });expect(result.success).toBe(true);if (result.success) expect(result.data.SECRET_SCANNING_SCAN_TIMEOUT).toBe(expected);@@ -59,15 +56,11 @@ describe("secret scanning timeouts", () => {describe("legacy `_MS` variables", () => {test("supplies the value when the duration variable is unset", () => {vi.stubEnv("SECRET_SCANNING_CLONE_TIMEOUT_MS", "60000");- vi.stubEnv("SECRET_SCANNING_STUCK_SCAN_TIMEOUT_MS", "5400000");const result = parse({});expect(result.success).toBe(true);- if (result.success) {- expect(result.data.SECRET_SCANNING_CLONE_TIMEOUT).toBe(60 * 1000);- expect(result.data.SECRET_SCANNING_STUCK_SCAN_TIMEOUT).toBe(90 * 60 * 1000);- }+ if (result.success) expect(result.data.SECRET_SCANNING_CLONE_TIMEOUT).toBe(60 * 1000);});test("loses to the duration variable when both are set", () => {@@ -98,44 +91,27 @@ describe("secret scanning timeouts", () => {});describe("stuck scan threshold", () => {- test("must leave room for a clone, a scan and the fixed overhead", () => {- const result = parse({- SECRET_SCANNING_CLONE_TIMEOUT: "10m",- SECRET_SCANNING_SCAN_TIMEOUT: "10m",- SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "20m"- });-- expect(issuesFor(result, "SECRET_SCANNING_STUCK_SCAN_TIMEOUT")).toEqual([- "SECRET_SCANNING_STUCK_SCAN_TIMEOUT (1200000ms) must exceed SECRET_SCANNING_CLONE_TIMEOUT + SECRET_SCANNING_SCAN_TIMEOUT plus 300000ms of measurement and bookkeeping (1500000ms), otherwise healthy in-flight scans are reaped as stuck."- ]);- });-- test("is rejected when it exactly equals the scan budget", () => {- const result = parse({- SECRET_SCANNING_CLONE_TIMEOUT: "1m",- SECRET_SCANNING_SCAN_TIMEOUT: "1m",- SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "7m"- });+ test("leaves room for a clone, a scan and the fixed overhead", () => {+ const result = parse({ SECRET_SCANNING_CLONE_TIMEOUT: "10m", SECRET_SCANNING_SCAN_TIMEOUT: "20m" });- expect(result.success).toBe(false);+ expect(result.success).toBe(true);+ if (result.success) expect(getSecretScanningStuckScanTimeout(result.data)).toBe(35 * 60 * 1000);});- test("is accepted one millisecond above the scan budget", () => {- const result = parse({- SECRET_SCANNING_CLONE_TIMEOUT: "1m",- SECRET_SCANNING_SCAN_TIMEOUT: "1m",- SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "420001"- });+ test("tracks the defaults", () => {+ const result = parse({});expect(result.success).toBe(true);+ if (result.success) expect(getSecretScanningStuckScanTimeout(result.data)).toBe(25 * 60 * 1000);});- test("weighs the legacy variables the same way", () => {+ test("tracks the legacy variables the same way", () => {vi.stubEnv("SECRET_SCANNING_SCAN_TIMEOUT_MS", "3600000");- const result = parse({ SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "1h" });+ const result = parse({});- expect(result.success).toBe(false);+ expect(result.success).toBe(true);+ if (result.success) expect(getSecretScanningStuckScanTimeout(result.data)).toBe(75 * 60 * 1000);});});});@@ -183,9 +159,9 @@ describe("deprecation warning", () => {});test("warns even when the replacement is set, because the legacy value is then dead weight", () => {- vi.stubEnv("SECRET_SCANNING_STUCK_SCAN_TIMEOUT_MS", "3600000");+ vi.stubEnv("SECRET_SCANNING_CLONE_TIMEOUT_MS", "600000");- parse({ SECRET_SCANNING_STUCK_SCAN_TIMEOUT: "2h" });+ parse({ SECRET_SCANNING_CLONE_TIMEOUT: "2h" });expect(warn).toHaveBeenCalledTimes(1);});diff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdxindex 2a970d4f1d..1794bf68c9 100644--- a/docs/self-hosting/configuration/envars.mdx+++ b/docs/self-hosting/configuration/envars.mdx@@ -1062,12 +1062,6 @@ You can configure third-party app connections for re-use across Infisical ProjecDefaults to `5120` (5 GB). Set to `0` to disable.</ParamField>- <ParamField query="SECRET_SCANNING_STUCK_SCAN_TIMEOUT" type="string" default="1h" optional>- How long a scan may stay in progress before it is assumed dead, meaning its worker was killed,- and marked failed. Takes a duration string such as `90s`, `10m`, or `2h`. Defaults to `1h`. Must- exceed the clone and scan timeouts plus the time a scan spends measuring the repository and- writing its results; the server refuses to start otherwise.- </ParamField></Accordion>## Observability