fix(database): Prisma + Neon throws "Unexpected server response: 101" due to forced ws constructor
Describe the bug
In packages/database/index.ts, neonConfig.webSocketConstructor = ws; explicitly configures the Neon Serverless driver to use the Node ws package.
When executing queries (such as database.page.findMany()) within Next.js Server Components (with Turbopack / Bun / Node runtime), the WebSocket handshake response (101 Switching Protocols) triggers an unexpected-response handler in the ws package, throwing:
Error: Unexpected server response: 101
{ clientVersion: "7.4.2" }In Prisma 7+ with @prisma/adapter-neon, global WebSocket is natively supported across modern runtimes, so overriding webSocketConstructor with ws is unnecessary and causes connection failures in Next.js Server Component environments.
next-forge version 6.0.2
To Reproduce Steps to reproduce the behavior:
- Run
bun run dev - Access
http://localhost:3000/(which runsdatabase.page.findMany()inapps/app/app/(authenticated)/page.tsx) - See 500 runtime error with message
Error: Unexpected server response: 101and{ clientVersion: "7.4.2" }
Expected behavior Prisma Client connects to Neon database smoothly without WebSocket handshake errors.
Desktop:
- OS: macOS / Linux
- Node: 20+ / Bun: 1.3+
Source: vercel/next-forge