Skip to content

fix(webapp): honor the configured database connect timeout - #4513

Merged
matt-aitken merged 1 commit into
mainfrom
feature/tri-12977-fix-prisma-clients-set-connection_timeout-ignored-instead-of
Aug 5, 2026
Merged

fix(webapp): honor the configured database connect timeout#4513
matt-aitken merged 1 commit into
mainfrom
feature/tri-12977-fix-prisma-clients-set-connection_timeout-ignored-instead-of

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

Every Prisma client built its connection URL with a connection_timeout query param, but the Postgres connector's parameter is connect_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 with Can't reach database server even though the database was healthy.

Fix

All four client builders now construct their connection URL through one shared helper (buildPrismaConnectionUrl) that sets connect_timeout, so the configured value actually applies, and the parameter name lives in exactly one place. Covered by a unit test.

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.
@changeset-bot

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5999c88

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitaiBot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Added buildPrismaConnectionUrl with typed connection parameters and PostgreSQL timeout query parameters. Added tests for generated and preserved URL parameters. Updated writer, replica, and run-ops database clients to use the shared builder. Added a changelog entry for the database connection timeout fix.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Description check⚠️ WarningThe description explains the issue and fix but omits the required issue, checklist, testing details, changelog, and screenshots sections.Add the required template sections and complete the checklist, testing steps, changelog, screenshots, and issue reference.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly and concisely describes the main change: honoring the configured database connect timeout.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/tri-12977-fix-prisma-clients-set-connection_timeout-ignored-instead-of

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ericallam
ericallam marked this pull request as ready for review August 5, 2026 14:49

@devin-ai-integrationdevin-ai-integrationBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@matt-aitken
matt-aitken merged commit 3039bc1 into mainAug 5, 2026
42 checks passed
@matt-aitken
matt-aitken deleted the feature/tri-12977-fix-prisma-clients-set-connection_timeout-ignored-instead-of branch August 5, 2026 14:52
@github-actionsgithub-actionsBot mentioned this pull request Aug 5, 2026
ericallam added a commit that referenced this pull request Aug 5, 2026
…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.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ericallam@matt-aitken