Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

retry in case of stream failure since inserting operations are idepotent

Thiago Araujo da Silvaedf51db9ec93
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.test.ts b/backend/src/ee/services/audit-log/audit-log-queue.test.ts
index 3dabee860f..9bb2b1e762 100644
--- a/backend/src/ee/services/audit-log/audit-log-queue.test.ts
+++ b/backend/src/ee/services/audit-log/audit-log-queue.test.ts
@@ -267,14 +267,14 @@ describe("audit-log-queue unified consumer", () => {
expect(outboxOrder).toBeLessThan(trimOrder);
});
- test("outbox failure after a successful insert still trims", async () => {
+ test("outbox failure after a successful insert skips the trim so the batch is reprocessed", async () => {
const { consumer, auditLogStreamOutboxService, keyStore } = await createHarness({ streamsEnabled: true });
auditLogStreamOutboxService.enqueueForLogs.mockRejectedValueOnce(new Error("outbox down"));
keyStore.streamCollect.mockResolvedValueOnce(collectResult([streamEntry()]));
await consumer();
- expect(keyStore.streamTrim).toHaveBeenCalledTimes(1);
+ expect(keyStore.streamTrim).not.toHaveBeenCalled();
});
test("does not fan out to the outbox when AUDIT_LOG_STREAMS_ENABLED is false", async () => {
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.ts b/backend/src/ee/services/audit-log/audit-log-queue.ts
index 1cb4425e31..55e2664827 100644
--- a/backend/src/ee/services/audit-log/audit-log-queue.ts
+++ b/backend/src/ee/services/audit-log/audit-log-queue.ts
@@ -238,13 +238,14 @@ export const auditLogQueueServiceFactory = async ({
}
if (getConfig().AUDIT_LOG_STREAMS_ENABLED) {
- // Fan out to the outbox and wake provider drainers. A failure here must not block the
- // trim: the logs are already in the system of record, and the outbox/drain machinery
- // retries delivery independently. Holding the trim hostage would wedge ingestion.
try {
await auditLogStreamOutboxService.enqueueForLogs(enriched);
} catch (error) {
- logger.error(error, "audit-log-queue: Failed to enqueue audit logs to stream outbox; continuing to trim");
+ logger.error(
+ error,
+ "audit-log-queue: Failed to enqueue audit logs to stream outbox; skipping trim so the batch is reprocessed"
+ );
+ return;
}
}