Prisma "Timed out fetching a new connection from the connection pool" in CI
Prisma keeps a bounded connection pool. When more concurrent queries are in flight than the pool allows, requests wait; if none frees up within the timeout, Prisma throws a pool timeout. Parallel CI tests hit this fast.
What this error means
Tests fail with "Timed out fetching a new connection from the connection pool. More info: ... (Current connection pool timeout: 10, connection limit: N)" under parallelism.
Timed out fetching a new connection from the connection pool. More info: https://pris.ly/d/connection-pool
(Current connection pool timeout: 10, connection limit: 5)Common causes
Parallel work exceeds the pool size
A test runner executing many suites in parallel opens more concurrent queries than the connection_limit allows, so requests time out waiting.
Leaked or long-held connections
Long transactions or clients that are never disconnected hold connections, starving the pool for other queries.
How to fix it
Raise the connection limit or lower concurrency
- Increase
connection_limitin the URL, within the database max_connections. - Or reduce test worker parallelism so fewer queries run at once.
- Reuse a single PrismaClient rather than one per test.
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/app?connection_limit=15Increase the pool timeout for bursts
Give the pool longer to hand out a connection when short bursts of concurrency are expected.
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/app?connection_limit=10&pool_timeout=30How to prevent it
- Size
connection_limitto your CI concurrency and DB max_connections. - Share one PrismaClient instance across tests.
- Disconnect clients and avoid long-held transactions.