Miguel-Adaptavist
PPrisma
•Created by Miguel-Adaptavist on 5/7/2025 in #help-and-questions
Prisma Client (v.5.10.2) in a Next.js project deployed in Vercel. Use or not the explicit disconnect
Hi! I'm using Prisma (v.5.10.2) in a Next.js project on Vercel. Our endpoint, triggered every 30 minutes by a cron job, interacts with a Neon serverless database. We've seen errors P1017 or P2024 in Vercel logs. The app retries operations up to four times with delays.
Vercel support suggested explicitly disconnecting to prevent Prisma errors, referencing this: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-management#calling-disconnect-explicitly. They recommended:
"
However, I have some concerns about implementing this. According to this documentation: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#do-not-explicitly-disconnect-1, explicit disconnection isn't necessary in serverless environments. Additionally, our function isn't something that "runs infrequently" since it executes every 30 minutes.
They also suggested the disconnect approach because Vercel uses function bundling (https://vercel.com/docs/functions/configuring-functions/advanced-configuration#bundling-vercel-functions) and mentioned that "Our engineer suggested the disconnect as you can see the reused connections are causing problems [...]"
I would like to know if Vercel's support advice is accurate and whether using an explicit disconnect could be a viable option in our scenario.
Thanks!
2 replies