skills/claudeception/examples/prisma-connection-pool-exhaustion/SKILL.md
Fix Prisma "Too many connections" and connection pool exhaustion errors in serverless environments (Vercel, AWS Lambda, Netlify). Use when: (1) Error "P2024: Timed out fetching a new connection from the pool", (2) PostgreSQL "too many connections for role", (3) Database works locally but fails in production serverless, (4) Intermittent database timeouts under load.
npx skillsauth add aresbit/matebot prisma-connection-pool-exhaustionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Serverless functions create a new Prisma client instance on each cold start. Each instance opens multiple database connections (default: 5 per instance). With many concurrent requests, this quickly exhausts the database's connection limit (often 20-100 for managed databases).
This skill applies when you see:
P2024: Timed out fetching a new connection from the connection poolFATAL: too many connections for role "username"Too many connectionsnpm run dev but fails in productionEnvironment indicators:
The recommended solution is to use a connection pooler like PgBouncer or Prisma Accelerate, which sits between your serverless functions and the database.
For Supabase:
# .env
# Use the pooled connection string (port 6543, not 5432)
DATABASE_URL="postgresql://user:[email protected]:6543/postgres?pgbouncer=true"
For Neon:
# .env
DATABASE_URL="postgresql://user:[email protected]/dbname?sslmode=require"
# Neon has built-in pooling
For Prisma Accelerate:
npx prisma generate --accelerate
In your schema.prisma:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// Limit connections per Prisma instance
relationMode = "prisma"
}
In your connection URL or Prisma client:
// lib/prisma.ts
import { PrismaClient } from '@prisma/client'
const globalForPrisma = global as unknown as { prisma: PrismaClient }
export const prisma = globalForPrisma.prisma || new PrismaClient({
datasources: {
db: {
url: process.env.DATABASE_URL + '?connection_limit=1'
}
}
})
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
Prevent hot-reload from creating new clients:
// lib/prisma.ts
import { PrismaClient } from '@prisma/client'
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined
}
export const prisma = globalForPrisma.prisma ?? new PrismaClient()
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
Add these to your connection string:
?connection_limit=1&pool_timeout=20&connect_timeout=10
connection_limit=1: One connection per serverless instancepool_timeout=20: Wait up to 20s for available connectionconnect_timeout=10: Fail fast if can't connect in 10sAfter applying fixes:
npx autocannon -c 100 -d 30 https://your-app.com/api/testBefore (error under load):
[ERROR] PrismaClientKnownRequestError:
Invalid `prisma.user.findMany()` invocation:
Timed out fetching a new connection from the connection pool.
After (with connection pooling):
# Using Supabase pooler URL
DATABASE_URL="postgresql://[email protected]:6543/postgres?pgbouncer=true&connection_limit=1"
Database connections stable at 10-15 even under heavy load.
connection_limit=1 is aggressive; start there and increase if you see latencydocumentation
Generate and edit Word documents (.docx). Supports professional documents including covers, charts, track-changes editing, and more. Suitable for any .docx creation or modification task.
tools
--- name: discord description: Use when you need to control Discord from OpenClaw via the discord tool: send messages, react, post or upload stickers, upload emojis, run polls, manage threads/pins/search, create/edit/delete channels and categories, fetch permissions or member/role/channel info, or handle moderation actions in Discord DMs or channels. metadata: {"openclaw":{"emoji":"🎮","requires":{"config":["channels.discord"]}}} --- # Discord Actions ## Overview Use `discord` to manage messa
tools
Run Codex CLI, Claude Code, OpenCode, or Pi Coding Agent via background process for programmatic control.
tools
Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawdhub CLI.