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
fix test URL and update some comments
Matheus Nogueira32d8dc11cd3a
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 472302c53d..719013f4ee 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -549,6 +549,8 @@ Queue handler factories (e.g., `src/services/secret/secret-queue.ts`) follow theRecurring work runs through the cron manager in `src/lib/cron/cron-job.ts` (`cronJobFactory`). A single instance is constructed in `src/server/routes/index.ts` (~line 541) and injected as `cronJob` into any service that needs to schedule periodic work. The factory exposes `register`, `start`, and `stop`; `start` is called once after construction, and `stop` is invoked during graceful shutdown to drain in-flight handlers.+**Only `general-workers` pods start the manager's timers**, so only they execute a scheduled handler; every pod still calls `register`. The separate `cronJobs` array in `src/server/routes/index.ts` is deliberately **not** gated: those refresh the process's own caches (license, rate limits, env overrides), not fleet work.+**Why this exists instead of BullMQ repeatables**: cron runs are coordinated across pods via a slot-election scheme (5 participant slots backed by Redis SET NX/PX) plus per-run redlocks, so each fire executes exactly once across the fleet without the orphaned-scheduler / duplicate-execution failure modes the BullMQ `JobScheduler` had. The manager also handles crash recovery via lease TTLs, hang recovery via per-handler timeouts, and bounded exponential backoff that won't overlap with the next scheduled fire.**Registering a cron job**:diff --git a/backend/e2e-test/run-modes.spec.ts b/backend/e2e-test/run-modes.spec.tsindex 29cc2abdc1..11e1cef170 100644--- a/backend/e2e-test/run-modes.spec.ts+++ b/backend/e2e-test/run-modes.spec.ts@@ -16,7 +16,7 @@ import { mockSmtpServer } from "./mocks/smtp";const API_ROUTES = [{ method: "GET" as const, url: "/api/v1/admin/config", requestUrl: "/api/v1/admin/config" },{ method: "GET" as const, url: "/api/v2/users/me/organizations", requestUrl: "/api/v2/users/me/organizations" },- { method: "GET" as const, url: "/api/v4/secrets/", requestUrl: "/api/v4/secrets" },+ { method: "GET" as const, url: "/api/v4/secrets", requestUrl: "/api/v4/secrets" }];describe("INFISICAL_RUN_MODES route registration", () => {diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex e51cf0de57..8a43ff4b70 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -585,7 +585,9 @@ export const registerRoutes = async (const redlock = new Redlock([redis], { retryCount: 0 });const cronJob = cronJobFactory({ redis, redlock });- cronJob.start();+ if (envConfig.isGeneralWorkerRunModeEnabled) {+ cronJob.start();+ }// Reached from the gateway proxy layer in src/lib, which has no DI, so it is installed as a module// singleton rather than threaded through every call site.@@ -4218,6 +4220,9 @@ export const registerRoutes = async (globalThis.testServices = server.services;}+ // Not gated by run mode, unlike the cron manager above: these refresh this process's own caches+ // (env overrides, license plan, rate limits, admin integration config), so an API pod that stopped+ // running them would serve stale config rather than shed background work.const cronJobs: CronJob[] = [];if (appCfg.isProductionMode) {const rateLimitSyncJob = await rateLimitService.initializeBackgroundSync();@@ -4352,8 +4357,7 @@ export const registerRoutes = async (});// A worker-only pod still serves /api/status so liveness and readiness probes keep working, but- // none of the product API. Everything above this point (service wiring, queue workers, crons) runs- // in every run mode.+ // none of the product API.if (envConfig.isApiRunModeEnabled) {// register special routesawait server.register(registerCertificateEstRouter, { prefix: "/.well-known/est" });