N
Neon2y ago
conventional-tan

Pooled connection TS error with PrismaNeon

I'm using the Neon Serverless driver with Prisma, but have a TS issue I'm not sure how to address. I tried extending the object type to add a "flavour" but that failed. I'm following this documentation:
https://neon.tech/docs/guides/prisma#use-the-neon-serverless-driver-with-prisma
https://neon.tech/docs/guides/prisma#use-the-neon-serverless-driver-with-prisma
The error I get is "Property 'flavour' is missing in type 'PrismaNeon' but required in type 'DriverAdapter'.ts(2741)"
No description
2 Replies
flat-fuchsia
flat-fuchsia2y ago
I have something similar with -
import { Pool, neonConfig } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import { PrismaClient } from "@prisma/client";
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);

declare global {
var sql: PrismaClient | undefined;
}

const sql = globalThis.sql || new PrismaClient({ adapter });

if (process.env.NODE_ENV !== "production") globalThis.sql = sql;

export default sql;
import { Pool, neonConfig } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import { PrismaClient } from "@prisma/client";
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);

declare global {
var sql: PrismaClient | undefined;
}

const sql = globalThis.sql || new PrismaClient({ adapter });

if (process.env.NODE_ENV !== "production") globalThis.sql = sql;

export default sql;
schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
...
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
...
dependencies -
...
"@neondatabase/serverless": "^0.6.1",
"@prisma/adapter-neon": "^5.8.0",
"@prisma/client": "^5.8.0",
...
"dotenv": "^16.3.1",
...
"ws": "^8.16.0"
...
"@neondatabase/serverless": "^0.6.1",
"@prisma/adapter-neon": "^5.8.0",
"@prisma/client": "^5.8.0",
...
"dotenv": "^16.3.1",
...
"ws": "^8.16.0"
this isn't throwing the type error in my env
conventional-tan
conventional-tanOP2y ago
@siegerts indeed, I adjusted the deps version and it solved it - had to downgrade serverless and neon-adapter tho
No description

Did you find this page helpful?