Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/web/src/trpc/commands/tasks/__tests__/delete.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions apps/web/src/trpc/commands/tasks/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,23 @@ export async function deleteTasksCommand(
.from(taskArtifacts)
.where(inArray(taskArtifacts.taskId, taskIdsToDelete));

// Delete S3 objects for these artifacts (best-effort).
// Delete S3 objects before removing their retry metadata.
let s3Result = { deleted: 0, errors: 0 };

if (artifactsToDelete.length > 0) {
try {
s3Result = await deleteArtifactsBatch(
artifactsToDelete.map((artifact) => ({
taskId: artifact.taskId!,
artifactId: artifact.id,
path: artifact.path,
version: artifact.version,
})),
s3Result = await deleteArtifactsBatch(
artifactsToDelete.map((artifact) => ({
taskId: artifact.taskId!,
artifactId: artifact.id,
path: artifact.path,
version: artifact.version,
})),
);

if (s3Result.errors > 0) {
throw new Error(
`Failed to delete ${s3Result.errors} artifact objects for tasks: ${taskIdsToDelete.join(', ')}`,
);

if (s3Result.errors > 0) {
console.warn(
`[deleteTasksCommand] S3 deletion had ${s3Result.errors} errors for tasks: ${taskIdsToDelete.join(', ')}`,
);
}
} catch (s3Error) {
console.error('[deleteTasksCommand] S3 deletion error:', s3Error);
}
}

Expand Down
Loading