Skip to content

Commit e4fde4d

Browse files
fix: Playwright user cleanup deadlock in E2E (calcom#25677)
* fix: increase Docker build MAX_OLD_SPACE_SIZE to 8192 to fix OOM Co-Authored-By: [email protected] <[email protected]> * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 6c21a12 commit e4fde4d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

apps/web/playwright/fixtures/users.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ export const createUsersFixture = (
592592
},
593593
deleteAll: async () => {
594594
const ids = store.users.map((u) => u.id);
595+
const trackedEmails = store.trackedEmails.map((e) => e.email);
596+
const teamIds = store.teams.map((org) => org.id);
597+
595598
if (emails) {
596599
const emailMessageIds: string[] = [];
597600
for (const user of store.trackedEmails.concat(store.users.map((u) => ({ email: u.email })))) {
@@ -607,11 +610,22 @@ export const createUsersFixture = (
607610
}
608611
}
609612

610-
await prisma.user.deleteMany({ where: { id: { in: ids } } });
611-
// Delete all users that were tracked by email(if they were created)
612-
await prisma.user.deleteMany({ where: { email: { in: store.trackedEmails.map((e) => e.email) } } });
613-
await prisma.team.deleteMany({ where: { id: { in: store.teams.map((org) => org.id) } } });
614-
await prisma.secondaryEmail.deleteMany({ where: { userId: { in: ids } } });
613+
// Run clean-up in a single transaction to avoid lock ordering deadlocks
614+
await prisma.$transaction(async (tx) => {
615+
if (ids.length > 0) {
616+
await tx.secondaryEmail.deleteMany({ where: { userId: { in: ids } } });
617+
await tx.user.deleteMany({ where: { id: { in: ids } } });
618+
}
619+
620+
if (trackedEmails.length > 0) {
621+
await tx.user.deleteMany({ where: { email: { in: trackedEmails } } });
622+
}
623+
624+
if (teamIds.length > 0) {
625+
await tx.team.deleteMany({ where: { id: { in: teamIds } } });
626+
}
627+
});
628+
615629
store.users = [];
616630
store.teams = [];
617631
store.trackedEmails = [];

0 commit comments

Comments
 (0)