The /health endpoint ran db.$queryRaw`SELECT 1` with no error handling.
When PostgreSQL hits max_connections (error 53300), the query threw
PrismaClientKnownRequestError, the error handler logged it as 'unhandled
error', and the reporter sent it to errors.bitreport.pt — creating an
error loop of one-off incidents from every health check.
Two fixes:
- /health now catches DB failures and returns 503 { status: 'degraded' }
instead of throwing, so a connection-starved health check degrades
gracefully rather than generating an error report.
- isTransientDatabaseError now filters 53300 (pool exhaustion) alongside
the existing 57P01/57P03/P1001/P1017 filters, so even if a 53300 surfaces
through another code path it does not trip the error loop.
Paperclip-Issue: BIT-33548