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 on new worker arch
Thiago Araujo da Silva3f095e3bec65
diff --git a/backend/src/services/alert/alert-dal.test.ts b/backend/src/services/alert/alert-dal.test.tsindex 00c3c651c4..043a3c1d14 100644--- a/backend/src/services/alert/alert-dal.test.ts+++ b/backend/src/services/alert/alert-dal.test.ts@@ -127,7 +127,7 @@ describe("alert dal", () => {// An empty result here is terminal for the event, so it must not come from a replica that has yet// to see the alert commit.- test("findEnabledForEvent reads the primary while the scheduled lookup keeps the replica", async () => {+ test("findEnabledForEvent reads the primary while the scheduled and list lookups keep the replica", async () => {const { dal, getReplicaReads } = buildDAL();await dal.findEnabledForEvent({@@ -140,6 +140,9 @@ describe("alert dal", () => {await dal.findEnabledByResourceType("approval.workflow");expect(getReplicaReads()).toBe(1);++ await dal.findActiveByScope({ orgId: "org-1", resourceType: "approval.workflow" });+ expect(getReplicaReads()).toBe(2);});test("findEnabledForEvent applies the same soft-deleted-project and enabled-channel filters", async () => {diff --git a/backend/src/services/alert/alert-dal.ts b/backend/src/services/alert/alert-dal.tsindex 2b02847cba..4df5979a52 100644--- a/backend/src/services/alert/alert-dal.ts+++ b/backend/src/services/alert/alert-dal.ts@@ -126,7 +126,7 @@ export const alertDALFactory = (db: TDbClient) => {tx?: Knex): Promise<TAlerts[]> => {try {- const query = (tx || db)(TableName.Alert)+ const query = (tx || db.replicaNode())(TableName.Alert).leftJoin(TableName.Project, `${TableName.Alert}.projectId`, `${TableName.Project}.id`).where(`${TableName.Alert}.orgId`, filter.orgId).where(`${TableName.Alert}.resourceType`, filter.resourceType)diff --git a/backend/src/services/event-outbox/event-outbox-queue.test.ts b/backend/src/services/event-outbox/event-outbox-queue.test.tsindex b4b3d21fe6..289cb0cc14 100644--- a/backend/src/services/event-outbox/event-outbox-queue.test.ts+++ b/backend/src/services/event-outbox/event-outbox-queue.test.ts@@ -8,15 +8,27 @@ vi.mock("@app/lib/logger", () => ({initLogger: () => {}}));+const config = {+ isGeneralWorkerRunModeEnabled: true,+ isSecondaryInstance: false,+ OTEL_TELEMETRY_COLLECTION_ENABLED: false+};+vi.mock("@app/lib/config/env", () => ({- getConfig: () => ({ isGeneralWorkerRunModeEnabled: true, OTEL_TELEMETRY_COLLECTION_ENABLED: false })+ getConfig: () => config}));+beforeEach(() => {+ config.isGeneralWorkerRunModeEnabled = true;+ config.isSecondaryInstance = false;+});+const KEY: TOutboxFlushKey = { consumer: "alert", resourceType: "approval.workflow", resourceId: "policy-1" };const buildQueue = (opts?: { keys?: TOutboxFlushKey[]; onDiscover?: () => Promise<void> }) => {const queued: { name: string; data: unknown; jobId?: string; attempts?: number }[] = [];const discoveredFor: string[][] = [];+ const registeredCrons: { name: string; enabled?: boolean }[] = [];let discoverCalls = 0;const factory = eventOutboxQueueFactory({@@ -26,7 +38,11 @@ const buildQueue = (opts?: { keys?: TOutboxFlushKey[]; onDiscover?: () => Promis},start: () => {}} as never,- cronJob: { register: () => {} } as never,+ cronJob: {+ register: (entry: { name: string; enabled?: boolean }) => {+ registeredCrons.push({ name: entry.name, enabled: entry.enabled });+ }+ } as never,eventOutboxRegistry: { names: () => ["alert", "audit"] },eventOutboxDAL: {findDueFlushKeys: async (_limit: number, consumers: string[]) => {@@ -44,7 +60,7 @@ const buildQueue = (opts?: { keys?: TOutboxFlushKey[]; onDiscover?: () => Promis} as never});- return { factory, queued, discoveredFor, getDiscoverCalls: () => discoverCalls };+ return { factory, queued, discoveredFor, registeredCrons, getDiscoverCalls: () => discoverCalls };};describe("event outbox relay", () => {@@ -105,6 +121,35 @@ describe("event outbox relay", () => {expect(queued).toHaveLength(0);});+ // Every other cron in the codebase sits behind this flag, and the docs promise a secondary region+ // runs no background jobs beyond audit logs.+ test("registers its crons disabled and never starts the relay on a secondary instance", async () => {+ vi.useFakeTimers();+ config.isSecondaryInstance = true;+ const { factory, registeredCrons, getDiscoverCalls } = buildQueue({ keys: [KEY] });++ factory.init();+ await vi.advanceTimersByTimeAsync(30_000);+ await factory.shutdown();+ vi.useRealTimers();++ expect(registeredCrons.map((cron) => cron.enabled)).toEqual([false, false]);+ expect(getDiscoverCalls()).toBe(0);+ });++ test("registers its crons enabled and starts the relay on a primary general worker", async () => {+ vi.useFakeTimers();+ const { factory, registeredCrons, getDiscoverCalls } = buildQueue({ keys: [KEY] });++ factory.init();+ await vi.advanceTimersByTimeAsync(30_000);+ await factory.shutdown();+ vi.useRealTimers();++ expect(registeredCrons.map((cron) => cron.enabled)).toEqual([true, true]);+ expect(getDiscoverCalls()).toBeGreaterThan(0);+ });+test("stops cleanly when nothing was ever started", async () => {const { factory } = buildQueue();diff --git a/backend/src/services/event-outbox/event-outbox-queue.ts b/backend/src/services/event-outbox/event-outbox-queue.tsindex ff8e96c1ea..85a162a2eb 100644--- a/backend/src/services/event-outbox/event-outbox-queue.ts+++ b/backend/src/services/event-outbox/event-outbox-queue.ts@@ -117,6 +117,7 @@ export const eventOutboxQueueFactory = ({name: CronJobName.EventOutboxStaleClaimSweeper,pattern: STALE_CLAIM_SWEEPER_CRON,runHashTtlS: CRON_RUN_HASH_TTL_S,+ enabled: !appCfg.isSecondaryInstance,handler: async () => {await eventOutboxService.sweepStaleClaims();}@@ -126,12 +127,13 @@ export const eventOutboxQueueFactory = ({name: CronJobName.EventOutboxCleanup,pattern: CLEANUP_CRON,runHashTtlS: CRON_RUN_HASH_TTL_S,+ enabled: !appCfg.isSecondaryInstance,handler: async () => {await eventOutboxService.pruneTerminalRows();}});- if (!appCfg.isGeneralWorkerRunModeEnabled) return;+ if (!appCfg.isGeneralWorkerRunModeEnabled || appCfg.isSecondaryInstance) return;$registerGauges();startTimer = setTimeout(