Skip to content

Commit 965f05c

Browse files
author
Mauricio Siu
committed
refactor: improve cleanup operation handling in postgres router
- Changed cleanup operations to use async functions for better error handling. - Replaced Promise.allSettled with a for loop to individually await each operation, allowing for more granular error management.
1 parent e316bea commit 965f05c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/dokploy/server/api/routers/postgres.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,16 @@ export const postgresRouter = createTRPCRouter({
282282
const backups = await findBackupsByDbId(input.postgresId, "postgres");
283283

284284
const cleanupOperations = [
285-
removeService(postgres.appName, postgres.serverId),
286-
cancelJobs(backups),
287-
removePostgresById(input.postgresId),
285+
async () => await removeService(postgres?.appName, postgres.serverId),
286+
async () => await cancelJobs(backups),
287+
async () => await removePostgresById(input.postgresId),
288288
];
289289

290-
await Promise.allSettled(cleanupOperations);
290+
for (const operation of cleanupOperations) {
291+
try {
292+
await operation();
293+
} catch (_) {}
294+
}
291295

292296
return postgres;
293297
}),

0 commit comments

Comments
 (0)