Skip to content

Commit

Permalink
Fix race-y bug in db.server.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
surma authored Oct 1, 2024
1 parent f050d49 commit 32d7bd5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/db.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ declare global {
var prisma: PrismaClient;
}

const prisma: PrismaClient = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
}

const prisma: PrismaClient = global.prisma || new PrismaClient();

export default prisma;

0 comments on commit 32d7bd5

Please sign in to comment.