Skip to content

Commit 41fdffe

Browse files
committed
merge: org-delete agent-purge enqueue is best-effort
2 parents 876ed56 + 18379a4 commit 41fdffe

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Deleting an organization now always succeeds, even if a temporary background hiccup prevents its agent chats from being cleaned up right away.

apps/webapp/app/services/deleteOrganization.server.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DeleteProjectService } from "./deleteProject.server";
66
import { getCurrentPlan } from "./platform.v3.server";
77
import { controlPlaneResolver } from "~/v3/runOpsMigration/controlPlaneResolver.server";
88
import { commonWorker } from "~/v3/commonWorker.server";
9+
import { logger } from "./logger.server";
910

1011
export class DeleteOrganizationService {
1112
#prismaClient: PrismaClient;
@@ -90,10 +91,18 @@ export class DeleteOrganizationService {
9091

9192
// Soft-delete the org's dashboard agent chats; retention purges them later. Enqueued,
9293
// not inline: the agent store is a separate database in cloud.
93-
await commonWorker.enqueue({
94-
id: `dashboardAgent.purgeOrganization:${organization.id}`,
95-
job: "dashboardAgent.purgeOrganization",
96-
payload: { organizationId: organization.id },
97-
});
94+
// Best-effort: a failed enqueue must not fail org deletion (the org is already deleted).
95+
try {
96+
await commonWorker.enqueue({
97+
id: `dashboardAgent.purgeOrganization:${organization.id}`,
98+
job: "dashboardAgent.purgeOrganization",
99+
payload: { organizationId: organization.id },
100+
});
101+
} catch (error) {
102+
logger.warn("Failed to enqueue dashboard agent purge for deleted organization", {
103+
organizationId: organization.id,
104+
error,
105+
});
106+
}
98107
}
99108
}

0 commit comments

Comments
 (0)