prisma-connection-pool-exhaustion_skill

This skill helps you resolve Prisma connection pool exhaustion in serverless environments by guiding pooling, limits, and singleton patterns to prevent P2024
  • Shell

1.8k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill blader/claudeception --skill prisma-connection-pool-exhaustion

  • SKILL.md4.6 KB

Overview

This skill fixes Prisma "Too many connections" and connection pool exhaustion errors in serverless environments (Vercel, AWS Lambda, Netlify). It provides concrete steps to reduce per-instance connections, enable pooling, and verify the fix so your production app stops hitting database connection limits. Use it when you see P2024 errors, database "too many connections" faults, or intermittent timeouts under load.

How this skill works

The skill inspects your Prisma configuration and deployment environment and applies three practical mitigations: route traffic through a connection pooler (PgBouncer, provider-built pooling, or Prisma Accelerate), limit per-client connections via connection string or Prisma client options, and apply a development singleton to avoid client proliferation during hot-reloads. It also recommends connection-string timeouts and verification steps to confirm connection counts fall within limits.

When to use it

  • You see P2024: Timed out fetching a new connection from the pool
  • PostgreSQL/MySQL reports "too many connections" in production
  • Works locally but fails in serverless production (Vercel, Lambda, Netlify)
  • Intermittent database timeouts or errors during traffic spikes
  • Database dashboard shows connections near the configured limit

Best practices

  • Use a pooling service (PgBouncer, provider-native pooling, or Prisma Accelerate) between functions and the database
  • Add connection parameters: connection_limit, pool_timeout, connect_timeout to the DATABASE_URL
  • Limit per-instance connections (start with connection_limit=1) and increase only if needed for latency
  • Apply a singleton Prisma client in development to avoid duplicates during hot reloads
  • Prefer provider docs for provider-specific pooling (Supabase, Neon, PlanetScale differences)

Example use cases

  • Deploying a Next.js API on Vercel that fails under concurrent requests due to many Prisma instances
  • Using Supabase or Neon where provider pooling can be enabled by swapping the port or URL parameter
  • Mitigating sudden spikes on serverless functions that push database connections above managed limits
  • Adding connection parameters to Prisma client to reduce timeouts and fail fast during connectivity issues

FAQ

Starting with connection_limit=1 is conservative. It reduces concurrency per instance and avoids exhaustion; if latency rises, increase the limit gradually while monitoring connection counts and query performance.

Do I still need the singleton in production?

No. The singleton prevents duplicate clients in development hot-reloads. In serverless production each instance is isolated, so you must rely on pooling and connection limits instead.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
prisma-connection-pool-exhaustion skill by blader/claudeception | VeilStrat