Skip to content

fix(db): revert statement_timeout startup options breaking pooled connections#4284

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/app-loading-issue
Apr 24, 2026
Merged

fix(db): revert statement_timeout startup options breaking pooled connections#4284
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/app-loading-issue

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Reverts fix(db): Set db statement timeout of 90 seconds #4276connection.options startup params are incompatible with the PlanetScale/PgBouncer pooler (prod already runs prepare: false), killing every new DB connection
  • Caused sign-in/social 500s, socket-token 500s, workspace UI stuck loading, and widespread "Failed query" errors in prod after v0.6.56 rolled out
  • Will re-land as SET LOCAL statement_timeout per-transaction (or via pooler-compatible URL param) in a follow-up

Type of Change

  • Bug fix

Testing

Tested manually — verified DB client opens without the broken startup options

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Building Building Preview, Comment Apr 24, 2026 6:31am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 24, 2026

PR Summary

Medium Risk
Touches global Postgres client initialization; while the change is small, it impacts all DB connectivity and query/transaction behavior (timeouts no longer enforced at connection startup).

Overview
Reverts the use of Postgres connection.options startup parameters (e.g., statement_timeout, idle_in_transaction_session_timeout) in both the shared packages/db client and the realtime socket DB client.

This restores compatibility with poolers like PgBouncer/PlanetScale that reject these startup params, at the cost of no longer enforcing those server-side timeouts via connection initialization.

Reviewed by Cursor Bugbot for commit b660e34. Configure here.

@waleedlatif1 waleedlatif1 merged commit ccb5f1e into staging Apr 24, 2026
9 of 10 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/app-loading-issue branch April 24, 2026 06:31
waleedlatif1 added a commit that referenced this pull request Apr 24, 2026
fix(db): revert statement_timeout startup options breaking pooled connections (#4284)
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR reverts #4276 by removing the connection.options startup parameters (-c statement_timeout=90000 -c idle_in_transaction_session_timeout=90000) from both the main packages/db client and the realtime socketDb client. These options are incompatible with PgBouncer/PlanetScale session pooling, which broke every new DB connection in production after v0.6.56. The prepare: false flag, which is the correct PgBouncer compatibility setting, remains in place in both clients.

Confidence Score: 5/5

Safe to merge — minimal, targeted revert of a confirmed production regression with no logic changes.

The change removes exactly the two connection.options lines that caused connection failures with PgBouncer, leaves all other pool config intact, and has been manually verified. No custom rules are violated. The only trade-off (loss of server-side query timeout guards) is acknowledged and tracked for a follow-up.

No files require special attention.

Important Files Changed

Filename Overview
packages/db/index.ts Removed incompatible connection.options startup params and their documentation comment; prepare: false retained for PgBouncer compatibility
apps/realtime/src/database/operations.ts Removed identical connection.options block from socketDb; pool config otherwise unchanged

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Pool as PgBouncer/PlanetScale Pooler
    participant DB as PostgreSQL

    Note over App,DB: Before revert (broken)
    App->>Pool: New connection request
    Pool->>DB: Connect + send startup options (-c statement_timeout=90000 ...)
    DB-->>Pool: ❌ Error: unrecognized option
    Pool-->>App: Connection failed (500 errors)

    Note over App,DB: After revert (this PR)
    App->>Pool: New connection request (prepare: false)
    Pool->>DB: Connect (no startup options)
    DB-->>Pool: ✅ Connection established
    Pool-->>App: Ready to query
Loading

Reviews (1): Last reviewed commit: "fix(db): revert statement_timeout startu..." | Re-trigger Greptile

Sign up for free to 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.

1 participant