fix(database): Prisma + Neon throws "Unexpected server response: 101" due to forced ws constructor

Author: Victory-7291Created Aug 16, 2026Updated Aug 16, 2026

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:

  1. Run bun run dev
  2. Access http://localhost:3000/ (which runs database.page.findMany() in apps/app/app/(authenticated)/page.tsx)
  3. See 500 runtime error with message Error: Unexpected server response: 101 and { 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+