PrismaP
Prisma15mo ago
4 replies
Yozamu

Neon adapter (driverAdapters) gives error on PrismaClient init

Hey there. I've wanted to run inngest events that trigger some prisma stuff, but I'm getting the error
PrismaClient failed to initialize because it wasn't configured to run in this environment

So I've decided to take a look at the driver adapters. After following the setup page to update my existing code, I have the following prisma client file :

import { Pool, neonConfig } from '@neondatabase/serverless';
import { PrismaNeon } from '@prisma/adapter-neon';
import dotenv from 'dotenv';
import ws from 'ws';

dotenv.config();
neonConfig.webSocketConstructor = ws;
const connectionString = `${process.env.DATABASE_URL}`;
const pool = new Pool({ connectionString });
const adapter = new PrismaNeon(pool);

const prismaClientSingleton = () => {
  return new PrismaClient({ adapter });
};

declare const globalThis: {
  prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma;


Unfortunately, it seems like there's an error when initializing the PrismaClient:
Property 'startTransaction' is missing in type 'PrismaNeon' but required in type 'DriverAdapter'.

I haven't been able to find much clues about what's going on. Any idea?
Was this page helpful?