From 0ac460fce3708faf54cbf8e969b03d3ac015e2df Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 25 Sep 2025 18:56:10 +0100 Subject: [PATCH] chore: when performing read operations we should use Promise.all, not $transaction (#24084) --- apps/api/v1/pages/api/users/_get.ts | 2 +- .../organizations/managed-organizations.repository.ts | 2 +- .../trpc/server/routers/viewer/organizations/getUser.handler.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/v1/pages/api/users/_get.ts b/apps/api/v1/pages/api/users/_get.ts index e719e31cb9..9966045ea1 100644 --- a/apps/api/v1/pages/api/users/_get.ts +++ b/apps/api/v1/pages/api/users/_get.ts @@ -59,7 +59,7 @@ export async function getHandler(req: NextApiRequest) { }; } - const [total, data] = await prisma.$transaction([ + const [total, data] = await Promise.all([ prisma.user.count({ where }), prisma.user.findMany({ where, take, skip }), ]); diff --git a/apps/api/v2/src/modules/organizations/organizations/managed-organizations.repository.ts b/apps/api/v2/src/modules/organizations/organizations/managed-organizations.repository.ts index 99ffa34e6c..bd5adbdf5e 100644 --- a/apps/api/v2/src/modules/organizations/organizations/managed-organizations.repository.ts +++ b/apps/api/v2/src/modules/organizations/organizations/managed-organizations.repository.ts @@ -68,7 +68,7 @@ export class ManagedOrganizationsRepository { managedOrganization: managedOrganizationFilter, }; - const [totalItems, linkRows] = await this.dbRead.prisma.$transaction([ + const [totalItems, linkRows] = await Promise.all([ this.dbRead.prisma.managedOrganization.count({ where }), this.dbRead.prisma.managedOrganization.findMany({ where, diff --git a/packages/trpc/server/routers/viewer/organizations/getUser.handler.ts b/packages/trpc/server/routers/viewer/organizations/getUser.handler.ts index 9ae4c9fb7e..e8a2959992 100644 --- a/packages/trpc/server/routers/viewer/organizations/getUser.handler.ts +++ b/packages/trpc/server/routers/viewer/organizations/getUser.handler.ts @@ -58,7 +58,7 @@ export async function getUserHandler({ input, ctx }: AdminVerifyOptions) { } // get requested user from database and ensure they are in the same organization - const [requestedUser, membership, teams] = await prisma.$transaction([ + const [requestedUser, membership, teams] = await Promise.all([ prisma.user.findUnique({ where: { id: input.userId }, select: {