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
refactor: replace CronJob with startLocalRefresh for background tasks
Victor Hugo dos Santos3acbe3cad8e2
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex f76d47527a..e863c2b402 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -630,6 +630,8 @@ Recurring work runs through the cron manager in `src/lib/cron/cron-job.ts` (`cro**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.+**Per-process refreshes use `startLocalRefresh` (`src/lib/cron/local-refresh.ts`), never the cron manager and never a raw `new CronJob`.** The cron manager runs a job once per fleet, which would leave every other pod's in-memory state stale; a wall-clock cron pattern makes every pod fire in the same second. The helper starts each process at a random offset within one interval (random per process on purpose, unlike the manager's deterministic hash), skips a tick while the previous run is in flight, logs and swallows errors, and unrefs its timers. Its `stop()` handle is what goes in `cronJobs`.+**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/package-lock.json b/backend/package-lock.jsonindex fc0b2911a0..d2ccfc40b9 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -89,7 +89,6 @@"bullmq": "^5.72.0","cassandra-driver": "^4.7.2","connect-redis": "^7.1.1",- "cron": "^3.1.7","cron-parser": "^5.5.0","dd-trace": "^5.40.0","dns-packet": "^5.6.1",@@ -11635,11 +11634,6 @@"long": "*"}},- "node_modules/@types/luxon": {- "version": "3.4.2",- "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz",- "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA=="- },"node_modules/@types/mime": {"version": "1.3.5","resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",@@ -14819,15 +14813,6 @@"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==","dev": true},- "node_modules/cron": {- "version": "3.1.7",- "resolved": "https://registry.npmjs.org/cron/-/cron-3.1.7.tgz",- "integrity": "sha512-tlBg7ARsAMQLzgwqVxy8AZl/qlTc5nibqYwtNGoCrd+cV+ugI+tvZC1oT/8dFH8W455YrywGykx/KMmAqOr7Jw==",- "dependencies": {- "@types/luxon": "~3.4.0",- "luxon": "~3.4.0"- }- },"node_modules/cron-parser": {"version": "5.5.0","resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-5.5.0.tgz",diff --git a/backend/package.json b/backend/package.jsonindex 5664cd9562..92b8f7963f 100644--- a/backend/package.json+++ b/backend/package.json@@ -243,7 +243,6 @@"bullmq": "^5.72.0","cassandra-driver": "^4.7.2","connect-redis": "^7.1.1",- "cron": "^3.1.7","cron-parser": "^5.5.0","dd-trace": "^5.40.0","dns-packet": "^5.6.1",diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.tsindex b99a2ee466..d3b7c36129 100644--- a/backend/src/ee/services/license/license-service.ts+++ b/backend/src/ee/services/license/license-service.ts@@ -1,9 +1,9 @@-import { CronJob } from "cron";import { Knex } from "knex";import { OrganizationActionScope } from "@app/db/schemas";import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";import { TEnvConfig } from "@app/lib/config/env";+import { startLocalRefresh } from "@app/lib/cron/local-refresh";import { verifyOfflineLicense } from "@app/lib/crypto";import { applyJitter } from "@app/lib/dates";import { BadRequestError, NotFoundError } from "@app/lib/errors";@@ -158,9 +158,11 @@ export const licenseServiceFactory = ({const initializeBackgroundSync = async () => {if (licenseKeyConfig?.isValid && licenseKeyConfig?.type === LicenseType.Online) {logger.info("Setting up background sync process to refresh onPremFeatures from License Server v2");- const job = new CronJob("*/10 * * * *", () => syncSelfHostedFeatures());- job.start();- return job;+ return startLocalRefresh({+ name: "self-hosted-license-sync",+ intervalMs: 10 * 60 * 1000,+ task: () => syncSelfHostedFeatures()+ });}};diff --git a/backend/src/ee/services/rate-limit/rate-limit-service.ts b/backend/src/ee/services/rate-limit/rate-limit-service.tsindex f63fca5cd5..ae0f024ed4 100644--- a/backend/src/ee/services/rate-limit/rate-limit-service.ts+++ b/backend/src/ee/services/rate-limit/rate-limit-service.ts@@ -1,5 +1,4 @@-import { CronJob } from "cron";-+import { startLocalRefresh } from "@app/lib/cron/local-refresh";import { logger } from "@app/lib/logger";import { TLicenseServiceFactory } from "../license/license-service";@@ -93,11 +92,11 @@ export const rateLimitServiceFactory = ({// initial sync upon startupawait syncRateLimitConfiguration();- // sync rate limits configuration every 10 minutes- const job = new CronJob("*/10 * * * *", syncRateLimitConfiguration);- job.start();-- return job;+ return startLocalRefresh({+ name: "rate-limit-config-sync",+ intervalMs: 10 * 60 * 1000,+ task: syncRateLimitConfiguration+ });};return {diff --git a/backend/src/ee/services/rate-limit/rate-limit-types.ts b/backend/src/ee/services/rate-limit/rate-limit-types.tsindex 0d54fc9ead..d46f490662 100644--- a/backend/src/ee/services/rate-limit/rate-limit-types.ts+++ b/backend/src/ee/services/rate-limit/rate-limit-types.ts@@ -1,4 +1,4 @@-import { CronJob } from "cron";+import { TLocalRefreshHandle } from "@app/lib/cron/local-refresh";export type TRateLimitUpdateDTO = {readRateLimit: number;@@ -33,6 +33,6 @@ export type RateLimitConfiguration = {export type TRateLimitServiceFactory = {getRateLimits: () => Promise<TRateLimit | undefined>;updateRateLimit: (updates: TRateLimitUpdateDTO) => Promise<TRateLimit>;- initializeBackgroundSync: () => Promise<CronJob<null, null> | undefined>;+ initializeBackgroundSync: () => Promise<TLocalRefreshHandle | undefined>;syncRateLimitConfiguration: () => Promise<void>;};diff --git a/backend/src/lib/cron/local-refresh.test.ts b/backend/src/lib/cron/local-refresh.test.tsnew file mode 100644index 0000000000..52108bc86f--- /dev/null+++ b/backend/src/lib/cron/local-refresh.test.ts@@ -0,0 +1,214 @@+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";++import { logger } from "@app/lib/logger";++import { startLocalRefresh, TLocalRefreshHandle } from "./local-refresh";++vi.mock("@app/lib/logger", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }+}));++const INTERVAL_MS = 5 * 60 * 1000;++describe("startLocalRefresh", () => {+ let handle: TLocalRefreshHandle | undefined;++ beforeEach(() => {+ vi.useFakeTimers();+ vi.clearAllMocks();+ });++ afterEach(() => {+ handle?.stop();+ handle = undefined;+ vi.useRealTimers();+ });++ test("first run lands at the random offset, within [0, interval)", async () => {+ const task = vi.fn().mockResolvedValue(undefined);+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => 0.4 });++ await vi.advanceTimersByTimeAsync(0.4 * INTERVAL_MS - 1);+ expect(task).not.toHaveBeenCalled();++ await vi.advanceTimersByTimeAsync(1);+ expect(task).toHaveBeenCalledTimes(1);+ });++ test.each([+ [0, 0],+ [0.999999999, INTERVAL_MS - 1],+ [1, INTERVAL_MS - 1],+ [-1, 0]+ ])("clamps offset for random()=%s to %sms", async (randomValue, expectedDelay) => {+ const task = vi.fn().mockResolvedValue(undefined);+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => randomValue });++ if (expectedDelay > 0) {+ await vi.advanceTimersByTimeAsync(expectedDelay - 1);+ expect(task).not.toHaveBeenCalled();+ }+ await vi.advanceTimersByTimeAsync(expectedDelay > 0 ? 1 : 0);+ expect(task).toHaveBeenCalledTimes(1);+ });++ test("default random source keeps the offset inside the interval", async () => {+ for (let i = 0; i < 20; i += 1) {+ const task = vi.fn().mockResolvedValue(undefined);+ const h = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task });+ // eslint-disable-next-line no-await-in-loop+ await vi.advanceTimersByTimeAsync(INTERVAL_MS - 1);+ expect(task).toHaveBeenCalledTimes(1);+ h.stop();+ }+ });++ test("runs every interval after the first run", async () => {+ const task = vi.fn().mockResolvedValue(undefined);+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => 0 });++ await vi.advanceTimersByTimeAsync(0);+ expect(task).toHaveBeenCalledTimes(1);++ await vi.advanceTimersByTimeAsync(INTERVAL_MS - 1);+ expect(task).toHaveBeenCalledTimes(1);++ await vi.advanceTimersByTimeAsync(1);+ expect(task).toHaveBeenCalledTimes(2);++ await vi.advanceTimersByTimeAsync(INTERVAL_MS * 3);+ expect(task).toHaveBeenCalledTimes(5);+ });++ test("skips ticks while a previous run is still in flight", async () => {+ let release: () => void = () => {};+ let active = 0;+ let maxActive = 0;+ const task = vi.fn(async () => {+ active += 1;+ maxActive = Math.max(maxActive, active);+ await new Promise<void>((resolve) => {+ release = resolve;+ });+ active -= 1;+ });++ handle = startLocalRefresh({ name: "slow", intervalMs: INTERVAL_MS, task, random: () => 0 });+ await vi.advanceTimersByTimeAsync(0);+ expect(task).toHaveBeenCalledTimes(1);++ await vi.advanceTimersByTimeAsync(INTERVAL_MS * 3);+ expect(task).toHaveBeenCalledTimes(1);+ expect(maxActive).toBe(1);+ expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining("previous run still in progress [name=slow]"));++ release();+ await vi.advanceTimersByTimeAsync(0);+ expect(logger.warn).toHaveBeenCalledWith(+ expect.objectContaining({ name: "slow", duration_ms: INTERVAL_MS * 3 }),+ expect.stringContaining("exceeded 1000ms")+ );++ await vi.advanceTimersByTimeAsync(INTERVAL_MS);+ expect(task).toHaveBeenCalledTimes(2);+ expect(maxActive).toBe(1);+ });++ test("an error in one run does not stop later runs", async () => {+ const task = vi+ .fn()+ .mockRejectedValueOnce(new Error("boom"))+ .mockImplementationOnce(() => {+ throw new Error("sync boom");+ })+ .mockResolvedValue(undefined);++ handle = startLocalRefresh({ name: "flaky", intervalMs: INTERVAL_MS, task, random: () => 0 });+ await vi.advanceTimersByTimeAsync(0);+ await vi.advanceTimersByTimeAsync(INTERVAL_MS);+ await vi.advanceTimersByTimeAsync(INTERVAL_MS);++ expect(task).toHaveBeenCalledTimes(3);+ expect(logger.error).toHaveBeenCalledTimes(2);+ expect(logger.error).toHaveBeenCalledWith(expect.any(Error), expect.stringContaining("[name=flaky]"));+ });++ test("logs duration at debug and warns only above the threshold", async () => {+ const task = vi.fn(async () => {+ await new Promise((resolve) => {+ setTimeout(resolve, 200);+ });+ });++ handle = startLocalRefresh({+ name: "timed",+ intervalMs: INTERVAL_MS,+ task,+ random: () => 0,+ slowRunThresholdMs: 500+ });+ await vi.advanceTimersByTimeAsync(200);++ expect(logger.debug).toHaveBeenCalledWith(+ expect.objectContaining({ name: "timed", duration_ms: 200 }),+ expect.stringContaining("[name=timed]")+ );+ expect(logger.warn).not.toHaveBeenCalled();+ });++ test("stop() before the first run cancels it", async () => {+ const task = vi.fn().mockResolvedValue(undefined);+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => 0.5 });++ handle.stop();+ await vi.advanceTimersByTimeAsync(INTERVAL_MS * 5);+ expect(task).not.toHaveBeenCalled();+ expect(vi.getTimerCount()).toBe(0);+ });++ test("stop() after runs have started cancels future runs", async () => {+ const task = vi.fn().mockResolvedValue(undefined);+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => 0 });++ await vi.advanceTimersByTimeAsync(INTERVAL_MS);+ expect(task).toHaveBeenCalledTimes(2);++ handle.stop();+ await vi.advanceTimersByTimeAsync(INTERVAL_MS * 5);+ expect(task).toHaveBeenCalledTimes(2);+ expect(vi.getTimerCount()).toBe(0);+ });++ test("stop() is idempotent", () => {+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task: vi.fn() });+ handle.stop();+ expect(() => handle?.stop()).not.toThrow();+ });++ test("offset and interval timers are unref'd so they never hold the process open", async () => {+ vi.useRealTimers();+ const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");+ const setIntervalSpy = vi.spyOn(globalThis, "setInterval");+ const task = vi.fn();++ try {+ handle = startLocalRefresh({ name: "t", intervalMs: INTERVAL_MS, task, random: () => 0 });+ const offsetTimer = setTimeoutSpy.mock.results[0]?.value as NodeJS.Timeout;+ expect(offsetTimer.hasRef()).toBe(false);++ await new Promise<void>((resolve) => {+ setTimeout(resolve, 20);+ });+ expect(task).toHaveBeenCalledTimes(1);+ const intervalTimer = setIntervalSpy.mock.results[0]?.value as NodeJS.Timeout;+ expect(intervalTimer.hasRef()).toBe(false);+ } finally {+ setTimeoutSpy.mockRestore();+ setIntervalSpy.mockRestore();+ }+ });++ test.each([0, -1, Number.NaN, Number.POSITIVE_INFINITY])("rejects invalid interval %s", (intervalMs) => {+ expect(() => startLocalRefresh({ name: "bad", intervalMs, task: vi.fn() })).toThrow(/positive number/);+ });+});diff --git a/backend/src/lib/cron/local-refresh.ts b/backend/src/lib/cron/local-refresh.tsnew file mode 100644index 0000000000..0dd8eb0b2f--- /dev/null+++ b/backend/src/lib/cron/local-refresh.ts@@ -0,0 +1,84 @@+import { logger } from "@app/lib/logger";++export type TLocalRefreshHandle = {+ stop: () => void;+};++type TStartLocalRefreshDTO = {+ name: string;+ intervalMs: number;+ task: () => Promise<void> | void;+ slowRunThresholdMs?: number;+ random?: () => number;+};++const DEFAULT_SLOW_RUN_THRESHOLD_MS = 1000;++// Refreshes state held in this process's memory, so it has to run on every pod; fleet-wide+// scheduled work belongs on the cron manager in ./cron-job instead. The offset is random per+// process on purpose: the point is that pods disagree, so they don't all hit the DB in the same second.+export const startLocalRefresh = ({+ name,+ intervalMs,+ task,+ slowRunThresholdMs = DEFAULT_SLOW_RUN_THRESHOLD_MS,+ random = Math.random+}: TStartLocalRefreshDTO): TLocalRefreshHandle => {+ if (!Number.isFinite(intervalMs) || intervalMs <= 0) {+ throw new Error(`Local refresh interval must be a positive number of milliseconds [name=${name}]`);+ }++ let stopped = false;+ let running = false;+ let timer: NodeJS.Timeout | undefined;++ const run = async () => {+ if (stopped) return;+ if (running) {+ logger.warn(`Local refresh skipped, previous run still in progress [name=${name}]`);+ return;+ }++ running = true;+ const startedAt = Date.now();+ try {+ await task();+ } catch (error) {+ logger.error(error, `Local refresh failed [name=${name}]`);+ } finally {+ running = false;+ const durationMs = Date.now() - startedAt;+ logger.debug(+ { name, duration_ms: durationMs },+ `Local refresh finished [name=${name}] [durationMs=${durationMs}]`+ );+ if (durationMs > slowRunThresholdMs) {+ logger.warn(+ { name, duration_ms: durationMs },+ `Local refresh exceeded ${slowRunThresholdMs}ms [name=${name}] [durationMs=${durationMs}]`+ );+ }+ }+ };++ const initialDelayMs = Math.max(0, Math.min(intervalMs - 1, Math.floor(random() * intervalMs)));++ timer = setTimeout(() => {+ if (stopped) return;+ timer = setInterval(() => {+ void run();+ }, intervalMs);+ timer.unref();+ void run();+ }, initialDelayMs);+ timer.unref();++ return {+ stop: () => {+ stopped = true;+ clearTimeout(timer);+ clearInterval(timer);+ timer = undefined;+ }+ };+};diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex d18edd49f3..ad53d518d1 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -2,7 +2,6 @@ import { registerBddNockRouter } from "@bdd_routes/bdd-nock-router";import type { ClickHouseClient } from "@clickhouse/client";import type { FastifyCookieOptions } from "@fastify/cookie";import cookie from "@fastify/cookie";-import { CronJob } from "cron";import { Cluster, Redis } from "ioredis";import { Knex } from "knex";import { monitorEventLoopDelay } from "perf_hooks";@@ -215,6 +214,7 @@ import { TKeyStoreFactory } from "@app/keystore/keystore";import { ApiDocsTags } from "@app/lib/api-docs";import { getConfig, TEnvConfig } from "@app/lib/config/env";import { cronJobFactory } from "@app/lib/cron/cron-job";+import { TLocalRefreshHandle } from "@app/lib/cron/local-refresh";import { crypto } from "@app/lib/crypto/cryptography";import { BadRequestError } from "@app/lib/errors";import { initGatewayLoadTracker } from "@app/lib/gateway-v2/gateway-load-tracker";@@ -4399,7 +4399,7 @@ export const registerRoutes = async (// 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[] = [];+ const cronJobs: TLocalRefreshHandle[] = [];if (appCfg.isProductionMode) {const rateLimitSyncJob = await rateLimitService.initializeBackgroundSync();if (rateLimitSyncJob) {diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.tsindex 48bcdaa2a4..726b809ecb 100644--- a/backend/src/server/routes/v1/sso-router.ts+++ b/backend/src/server/routes/v1/sso-router.ts@@ -10,7 +10,6 @@ import { Authenticator } from "@fastify/passport";import { requestContext } from "@fastify/request-context";import fastifySession from "@fastify/session";import RedisStore from "connect-redis";-import { CronJob } from "cron";import { Strategy as GitLabStrategy } from "passport-gitlab2";import { Strategy as GoogleStrategy } from "passport-google-oauth20";import { Strategy as OAuth2Strategy } from "passport-oauth2";@@ -18,6 +17,7 @@ import { z } from "zod";import { INFISICAL_PROVIDER_GITHUB_ACCESS_TOKEN } from "@app/lib/config/const";import { getConfig } from "@app/lib/config/env";+import { startLocalRefresh } from "@app/lib/cron/local-refresh";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { logger } from "@app/lib/logger";import { ms } from "@app/lib/ms";@@ -408,11 +408,11 @@ export const refreshOauthConfig = () => {export const initializeOauthConfigSync = async () => {logger.info("Setting up background sync process for oauth configuration");- // sync every 5 minutes- const job = new CronJob("*/5 * * * *", refreshOauthConfig);- job.start();-- return job;+ return startLocalRefresh({+ name: "oauth-config-sync",+ intervalMs: 5 * 60 * 1000,+ task: refreshOauthConfig+ });};export const registerSsoRouter = async (server: FastifyZodProvider) => {diff --git a/backend/src/services/microsoft-teams/microsoft-teams-service.ts b/backend/src/services/microsoft-teams/microsoft-teams-service.tsindex a9d1af8404..6a790bca6b 100644--- a/backend/src/services/microsoft-teams/microsoft-teams-service.ts+++ b/backend/src/services/microsoft-teams/microsoft-teams-service.ts@@ -6,12 +6,12 @@ import {Request,Response} from "botbuilder";-import { CronJob } from "cron";import { FastifyReply, FastifyRequest } from "fastify";import { OrganizationActionScope } from "@app/db/schemas";import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";+import { startLocalRefresh } from "@app/lib/cron/local-refresh";import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";import { logger } from "@app/lib/logger";@@ -163,11 +163,11 @@ export const microsoftTeamsServiceFactory = ({// initial sync upon startupawait $syncMicrosoftTeamsIntegrationConfiguration();- // sync rate limits configuration every 5 minutes- const job = new CronJob("*/5 * * * *", $syncMicrosoftTeamsIntegrationConfiguration);- job.start();-- return job;+ return startLocalRefresh({+ name: "microsoft-teams-config-sync",+ intervalMs: 5 * 60 * 1000,+ task: $syncMicrosoftTeamsIntegrationConfiguration+ });};const start = async () => {diff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.tsindex 5cdd4e0d39..417d77a09a 100644--- a/backend/src/services/super-admin/super-admin-service.ts+++ b/backend/src/services/super-admin/super-admin-service.ts@@ -1,5 +1,3 @@-import { CronJob } from "cron";-import {AccessScope,IdentityAuthMethod,@@ -22,6 +20,7 @@ import {overwriteSchema,validateOverrides} from "@app/lib/config/env";+import { startLocalRefresh } from "@app/lib/cron/local-refresh";import { crypto } from "@app/lib/crypto/cryptography";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { TIp } from "@app/lib/ip";@@ -1272,11 +1271,11 @@ export const superAdminServiceFactory = ({// initial sync upon startupawait $syncAdminIntegrationConfig();- // sync admin integrations config every 5 minutes- const job = new CronJob("*/5 * * * *", $syncAdminIntegrationConfig);- job.start();-- return job;+ return startLocalRefresh({+ name: "admin-integration-config-sync",+ intervalMs: 5 * 60 * 1000,+ task: $syncAdminIntegrationConfig+ });};const initializeEnvConfigSync = async () => {@@ -1284,11 +1283,11 @@ export const superAdminServiceFactory = ({await $syncEnvConfig();- // sync every 5 minutes- const job = new CronJob("*/5 * * * *", $syncEnvConfig);- job.start();-- return job;+ return startLocalRefresh({+ name: "env-config-sync",+ intervalMs: 5 * 60 * 1000,+ task: $syncEnvConfig+ });};const getEmailDomains = async ({ offset, limit, searchTerm }: TAdminGetEmailDomainsDTO) => {