Uh oh!
There was an error while loading. Please reload this page.
fix(webapp): honor the configured database connect timeout - #4513
Conversation
The Prisma connection URLs were built with a connection_timeout query param, which the Postgres connector ignores (the parameter is connect_timeout), so every client silently fell back to the 5s default instead of the configured value. Brief connection spikes could then exceed 5s while establishing a connection and surface as "Can't reach database server". All four clients now build their connection URL through one shared helper that sets connect_timeout, so the configured timeout actually applies.
|
WalkthroughAdded 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
…4515) ## Summary Follow-on to #4513. The database connect timeout is now honored, but a single global value has to serve three separate databases at once (control-plane, legacy run-ops, and run-ops). This adds optional per-client overrides for the Prisma pool and connect timeouts, one pair for the writer and one for the read replica of each of the three databases, each falling back to the shared `DATABASE_POOL_TIMEOUT` / `DATABASE_CONNECTION_TIMEOUT` when unset. That lets one database's clients run a fail-fast connect timeout (with a bounded pool wait) while another keeps more headroom, without a single knob forcing the same tradeoff everywhere. No behavior change until an override is set. It also tags each client's queries with its specific datasource (`control-plane` / `legacy-run-ops` / `run-ops`, writer or replica) via the `db.datasource` span attribute, so telemetry can attribute connection behavior to a specific database instead of just writer-vs-replica.
Summary
Every Prisma client built its connection URL with a
connection_timeoutquery param, but the Postgres connector's parameter isconnect_timeout. The misspelled param is silently ignored, so all clients fell back to Prisma's 5s default instead of the configured timeout. When establishing a new connection briefly took longer than 5s (for example during connection spikes), it failed withCan't reach database servereven though the database was healthy.Fix
All four client builders now construct their connection URL through one shared helper (
buildPrismaConnectionUrl) that setsconnect_timeout, so the configured value actually applies, and the parameter name lives in exactly one place. Covered by a unit test.