I want to leverage the Neon Serverless client + Prismaon an app deployed to Vercel Functions . Neon Docs specifies the following Client instantiation:
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 = wsconst connectionString = `${process.env.DATABASE_URL}`const pool = new Pool({ connectionString })const adapter = new PrismaNeon(pool)const prisma = new PrismaClient({ adapter })
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 = wsconst connectionString = `${process.env.DATABASE_URL}`const pool = new Pool({ connectionString })const adapter = new PrismaNeon(pool)const prisma = new PrismaClient({ adapter })
However, this results in the following runtime error on Vercel:
Uncaught Exception {"errorType":"TypeError","errorMessage":"t.mask is not a function","stack":["TypeError: t.mask is not a function"," at e.exports.mask (/var/task/.next/server/chunks/380.js:1:18610)"," at f.frame (/var/task/.next/server/chunks/380.js:1:37325)"," at f.send (/var/task/.next/server/chunks/380.js:1:39394)"," at L.send (/var/task/.next/server/chunks/380.js:2:9184)"," at Timeout._onTimeout (/var/task/.next/server/chunks/380.js:10:953)"," at listOnTimeout (node:internal/timers:569:17)"," at process.processTimers (node:internal/timers:512:7)"]}
Uncaught Exception {"errorType":"TypeError","errorMessage":"t.mask is not a function","stack":["TypeError: t.mask is not a function"," at e.exports.mask (/var/task/.next/server/chunks/380.js:1:18610)"," at f.frame (/var/task/.next/server/chunks/380.js:1:37325)"," at f.send (/var/task/.next/server/chunks/380.js:1:39394)"," at L.send (/var/task/.next/server/chunks/380.js:2:9184)"," at Timeout._onTimeout (/var/task/.next/server/chunks/380.js:10:953)"," at listOnTimeout (node:internal/timers:569:17)"," at process.processTimers (node:internal/timers:512:7)"]}
After googling around, I found out that this is a WebSocket problem (or rather lack of WS support in Vercel Functions) . I would like to ask what is the proper way to utilise the
Prisma is an open source, next generation ORM that lets you to manage and interact with your database. This guide covers the following topics Connect to Neon from Prisma Use connection pooling with Pr...