P
Prisma•2w ago
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
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;
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'.
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?
3 Replies
Nurul
Nurul•2w ago
Hello @Yozamu 👋 Is this happening on latest version of Prisma - v5.22.0? Is your repository open source? If yes, can you share with me so that I can try to reproduce this error?
Yozamu
YozamuOP•2w ago
Hi, thanks for your answer. It seems like, between the moment I've added prisma to my project, and needed the neon-adapter, there has indeed been a minor version change that changed the method name and created the mismatch! By upgrading prisma version to the latest, it solved the issue
Nurul
Nurul•2w ago
I am glad to hear that upgrading to the latest version of Prisma resolved the issue for you 🙌
Want results from more Discord servers?
Add your server