prisma 6.7.0 not working in production
i have router v7, prisma and neon application working well in development. i can login and out but when i deploy to netlify i got this error.
schema:
generator client {
provider = "prisma-client"
previewFeatures = ["queryCompiler", "driverAdapters"]
output = "../app/generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// directUrl = env("DATABASE_URL_UNPOOLED")
};
prisma client:
import { neonConfig } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import ws from "ws";
import dotenv from "dotenv";
import { PrismaClient } from "~/generated/prisma/client";
import { PrismaPg } from '@prisma/adapter-pg'
dotenv.config();
declare global {
/* eslint no-var: off */
var _prisma: PrismaClient | undefined;
}
neonConfig.webSocketConstructor = ws;
const connectionString =
${process.env.DATABASE_URL}
;
// const adapter = new PrismaPg({ connectionString })
// const adapter = new PrismaNeon(pool)
const adapter = new PrismaNeon({ connectionString });
//let prisma = new PrismaClient({adapter})
let prisma: PrismaClient;
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient({ adapter });
} else {
if (!global._prisma) {
global._prisma = new PrismaClient({ adapter });
// global._prisma.$connect();
}
prisma = global._prisma;
}
export default prisma;
8 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai
for a quick spin!You'll need to get the logs for the error, that error tells us nothing.
ERROR Uncaught Exception {"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Identifier 'dirname' has already been declared","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Identifier 'dirname' has already been declared"," at _loadUserApp (file:///var/runtime/index.mjs:1084:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]}


I ran into that same issue. It was ESM format but causing duplicate
__dirname
and __filename
declares. I spent too much time trying to figure out what was going wrong so I just made a patch script to run before deploying but after generating the client files.
I thought it was the way SST was bundling RR7 with serverless functions on AWS. Are you using SST, or serverless?serverless
?