Scheduling infrastructure for absolutely everyone.
fix: increase maxWait/Timeout invite members transaction (#12583)
Morgan07f42057fc7f
diff --git a/packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts b/packages/trpc/server/routers/viewer/teams/inviteMember/utils.tsindex fb0a38f8caa..2ea1ed579c2 100644--- a/packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts+++ b/packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts@@ -217,46 +217,49 @@ export async function createNewUsersConnectToOrgIfExists({autoAcceptEmailDomain?: string;connectionInfoMap: Record<string, ReturnType<typeof getOrgConnectionInfo>>;}) {- await prisma.$transaction(async (tx) => {- for (let index = 0; index < usernamesOrEmails.length; index++) {- const usernameOrEmail = usernamesOrEmails[index];- const { orgId, autoAccept } = connectionInfoMap[usernameOrEmail];- const [emailUser, emailDomain] = usernameOrEmail.split("@");- const username =- emailDomain === autoAcceptEmailDomain- ? slugify(emailUser)- : slugify(`${emailUser}-${emailDomain.split(".")[0]}`);-- const createdUser = await tx.user.create({- data: {- username,- email: usernameOrEmail,- verified: true,- invitedTo: input.teamId,- organizationId: orgId || null, // If the user is invited to a child team, they are automatically added to the parent org- teams: {- create: {- teamId: input.teamId,- role: input.role as MembershipRole,- accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted- },- },- },- });-- // We also need to create the membership in the parent org if it exists- if (parentId) {- await tx.membership.create({+ await prisma.$transaction(+ async (tx) => {+ for (let index = 0; index < usernamesOrEmails.length; index++) {+ const usernameOrEmail = usernamesOrEmails[index];+ const { orgId, autoAccept } = connectionInfoMap[usernameOrEmail];+ const [emailUser, emailDomain] = usernameOrEmail.split("@");+ const username =+ emailDomain === autoAcceptEmailDomain+ ? slugify(emailUser)+ : slugify(`${emailUser}-${emailDomain.split(".")[0]}`);++ const createdUser = await tx.user.create({data: {- teamId: parentId,- userId: createdUser.id,- role: input.role as MembershipRole,- accepted: autoAccept,+ username,+ email: usernameOrEmail,+ verified: true,+ invitedTo: input.teamId,+ organizationId: orgId || null, // If the user is invited to a child team, they are automatically added to the parent org+ teams: {+ create: {+ teamId: input.teamId,+ role: input.role as MembershipRole,+ accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted+ },+ },},});++ // We also need to create the membership in the parent org if it exists+ if (parentId) {+ await tx.membership.create({+ data: {+ teamId: parentId,+ userId: createdUser.id,+ role: input.role as MembershipRole,+ accepted: autoAccept,+ },+ });+ }}- }- });+ },+ { timeout: 10000 }+ );}export async function createProvisionalMemberships({