Summary
Plasmic codegen builds are failing on Vercel due to database connection pool exhaustion when pre-rendering pages with data sources.
Environment
- Plasmic Setup: Codegen mode
- Deployment Platform: Vercel
Issue Description
During the Vercel build process, when Plasmic attempts to pre-render pages that fetch data from our database, the build fails with 31 connection pool errors. It appears that multiple parallel pre-rendering processes are exhausting the available database connections.
Error Messages
1. "remaining connection slots are reserved for non-replication superuser connections"
2. "sorry, too many clients already"
3. TypeError: Cannot read properties of undefined (reading '0')
- This appears to be a secondary error caused by failed data fetching
Full Error Stack
Error: {"error":{"statusCode":400,"__plasmicIgnoreError":true,"message":"remaining connection slots are reserved for non-replication superuser connections"}}
at /vercel/path0/node_modules/@plasmicapp/data-sources/dist/index.js:334:13
at Generator.next (<anonymous>)
at fulfilled (/vercel/path0/node_modules/@plasmicapp/data-sources/dist/index.js:50:24)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Expected Behavior
- Plasmic should manage database connections efficiently during pre-rendering
- Connection pooling should be properly configured to handle parallel page generation
- Connections should be reused or properly closed after use
Actual Behavior
- Database connection limit is reached during build
- Multiple “PLASMIC: Encountered error when pre-rendering” messages
- Build fails with connection exhaustion errors