Skip to content

fix(postgres): absorb idle pool client errors without full reconnect - #1619

Merged
jhaynie merged 2 commits into
mainfrom
fix/postgres-pool-idle-error
Jul 20, 2026
Merged

fix(postgres): absorb idle pool client errors without full reconnect#1619
jhaynie merged 2 commits into
mainfrom
fix/postgres-pool-idle-error

Conversation

@jhaynie

@jhaynie jhaynie commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Absorb pg.Pool idle-client errors in PostgresPool instead of marking the pool dead and tearing it down
  • Only forward error when a consumer has attached a listener (avoids Bun/Node crash on unhandled error emit)
  • Keep query/connect transient retry; remove the idle-triggered full-pool reconnect path that killed healthy clients

Test plan

  • cd packages/postgres && bun test test/pool-compat.test.ts
  • cd packages/postgres && bun run typecheck && bun run build
  • After publish, verify Genesis dev:api no longer exits on Connection terminated unexpectedly idle disconnects

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Improved connection pool resilience when an idle database connection reports an error.
    • Prevented idle connection errors from unnecessarily closing the pool or triggering close/reconnect callbacks.
    • Ensured queries continue to work after an idle connection error, even without registered error listeners.
    • Clarified that close callbacks apply only to explicit pool-close events.

pg.Pool idle disconnects are self-healing; re-emitting error with no
listeners crashed Bun, and tearing down the pool killed healthy clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
@agentuity-agent

agentuity-agent Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🟢 Ready (deploy_31707426934435848766e277c4233fce) - 2026-07-20T20:53:00Z

View deployment logs with the Agentuity CLI:

agentuity cloud deployment logs deploy_31707426934435848766e277c4233fce --project-id=proj_5ed7da797bef771d65e1bd6946a052b1

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bdb65a1f-b446-4aee-a07a-12dbd389b2bd

📥 Commits

Reviewing files that changed from the base of the PR and between 0109029 and 907c351.

📒 Files selected for processing (2)
  • packages/postgres/src/pool.ts
  • packages/postgres/test/pool-compat.test.ts
📝 Walkthrough

Walkthrough

Changes

The PostgreSQL pool now absorbs idle-client errors without marking the pool disconnected or closing it, conditionally forwards error events, updates callback documentation, and tests continued query usability.

Changes

PostgreSQL idle error resilience

Layer / File(s) Summary
Idle client error handling
packages/postgres/src/pool.ts, packages/postgres/src/types.ts
Raw pool errors use _handleIdleClientError, which updates disconnect tracking and emits only when listeners exist; documentation describes idle disconnects as recoverable and excludes them from onclose.
Idle error compatibility validation
packages/postgres/test/pool-compat.test.ts
A regression test verifies that an idle error without listeners does not close or reconnect the pool and that subsequent queries continue to work.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

📦 Canary Packages Published

version: 3.1.9-907c351

Packages
Package Version URL
@agentuity/client 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-client-3.1.9-907c351.tgz
@agentuity/vite 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vite-3.1.9-907c351.tgz
@agentuity/postgres 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-postgres-3.1.9-907c351.tgz
@agentuity/server 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-server-3.1.9-907c351.tgz
@agentuity/sandbox 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-sandbox-3.1.9-907c351.tgz
@agentuity/migrate 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-migrate-3.1.9-907c351.tgz
@agentuity/genesis 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-genesis-3.1.9-907c351.tgz
@agentuity/vector 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vector-3.1.9-907c351.tgz
@agentuity/runtime 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-runtime-3.1.9-907c351.tgz
@agentuity/core 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-core-3.1.9-907c351.tgz
@agentuity/stream 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-stream-3.1.9-907c351.tgz
@agentuity/storage 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-storage-3.1.9-907c351.tgz
@agentuity/coder 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-3.1.9-907c351.tgz
@agentuity/db 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-db-3.1.9-907c351.tgz
@agentuity/claude-code 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-claude-code-3.1.9-907c351.tgz
@agentuity/analytics 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-analytics-3.1.9-907c351.tgz
@agentuity/telemetry 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-telemetry-3.1.9-907c351.tgz
@agentuity/drizzle 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-drizzle-3.1.9-907c351.tgz
create-agentuity 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/create-agentuity-3.1.9-907c351.tgz
@agentuity/keyvalue 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-keyvalue-3.1.9-907c351.tgz
@agentuity/webhook 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-webhook-3.1.9-907c351.tgz
@agentuity/aigateway 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-aigateway-3.1.9-907c351.tgz
@agentuity/cli 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-cli-3.1.9-907c351.tgz
@agentuity/email 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-email-3.1.9-907c351.tgz
@agentuity/pi 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-pi-3.1.9-907c351.tgz
@agentuity/config 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-config-3.1.9-907c351.tgz
@agentuity/coder-tui 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-tui-3.1.9-907c351.tgz
@agentuity/skills 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-skills-3.1.9-907c351.tgz
@agentuity/opencode 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-opencode-3.1.9-907c351.tgz
@agentuity/task 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-task-3.1.9-907c351.tgz
@agentuity/adapter 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-adapter-3.1.9-907c351.tgz
@agentuity/queue 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-queue-3.1.9-907c351.tgz
@agentuity/schema 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schema-3.1.9-907c351.tgz
@agentuity/schedule 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schedule-3.1.9-907c351.tgz
@agentuity/api 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-api-3.1.9-907c351.tgz
@agentuity/hono 3.1.9-907c351 https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-hono-3.1.9-907c351.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/client": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-client-3.1.9-907c351.tgz",
    "@agentuity/vite": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vite-3.1.9-907c351.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-postgres-3.1.9-907c351.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-server-3.1.9-907c351.tgz",
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-sandbox-3.1.9-907c351.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-migrate-3.1.9-907c351.tgz",
    "@agentuity/genesis": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-genesis-3.1.9-907c351.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vector-3.1.9-907c351.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-runtime-3.1.9-907c351.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-core-3.1.9-907c351.tgz",
    "@agentuity/stream": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-stream-3.1.9-907c351.tgz",
    "@agentuity/storage": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-storage-3.1.9-907c351.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-3.1.9-907c351.tgz",
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-db-3.1.9-907c351.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-claude-code-3.1.9-907c351.tgz",
    "@agentuity/analytics": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-analytics-3.1.9-907c351.tgz",
    "@agentuity/telemetry": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-telemetry-3.1.9-907c351.tgz",
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-drizzle-3.1.9-907c351.tgz",
    "create-agentuity": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/create-agentuity-3.1.9-907c351.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-keyvalue-3.1.9-907c351.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-webhook-3.1.9-907c351.tgz",
    "@agentuity/aigateway": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-aigateway-3.1.9-907c351.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-cli-3.1.9-907c351.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-email-3.1.9-907c351.tgz",
    "@agentuity/pi": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-pi-3.1.9-907c351.tgz",
    "@agentuity/config": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-config-3.1.9-907c351.tgz",
    "@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-tui-3.1.9-907c351.tgz",
    "@agentuity/skills": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-skills-3.1.9-907c351.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-opencode-3.1.9-907c351.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-task-3.1.9-907c351.tgz",
    "@agentuity/adapter": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-adapter-3.1.9-907c351.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-queue-3.1.9-907c351.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schema-3.1.9-907c351.tgz",
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schedule-3.1.9-907c351.tgz",
    "@agentuity/api": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-api-3.1.9-907c351.tgz",
    "@agentuity/hono": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-hono-3.1.9-907c351.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-client-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vite-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-postgres-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-server-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-sandbox-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-migrate-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-genesis-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-vector-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-runtime-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-core-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-stream-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-storage-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-db-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-claude-code-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-analytics-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-telemetry-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-drizzle-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/create-agentuity-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-keyvalue-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-webhook-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-aigateway-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-cli-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-email-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-pi-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-config-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-coder-tui-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-skills-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-opencode-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-task-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-adapter-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-queue-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schema-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-schedule-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-api-3.1.9-907c351.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-907c351/agentuity-hono-3.1.9-907c351.tgz

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/postgres/src/pool.ts`:
- Around line 514-532: Remove the unconditional this._stats.lastDisconnectedAt
update from _handleIdleClientError, since idle-client errors must not alter
pool-level disconnect statistics while the pool remains connected. If diagnostic
tracking is required by the existing stats design, use a dedicated idle-client
error timestamp instead of lastDisconnectedAt; otherwise leave the handler
limited to conditional error emission.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05db1ca7-0fc2-46cf-8651-44b03ee2595b

📥 Commits

Reviewing files that changed from the base of the PR and between 7d09725 and 0109029.

📒 Files selected for processing (3)
  • packages/postgres/src/pool.ts
  • packages/postgres/src/types.ts
  • packages/postgres/test/pool-compat.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Package Installation & Usage Test (node)
  • GitHub Check: Agentuity - docs-docs
  • GitHub Check: Queue CLI Tests (bun)
  • GitHub Check: Queue CLI Tests (node)
  • GitHub Check: Package Installation & Usage Test (bun)
  • GitHub Check: Framework Demo Tests
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: Testing Apps (local tests)
  • GitHub Check: Service Client Smoke Tests
  • GitHub Check: Migrate Chain (v1 → v2 → v3)
  • GitHub Check: Build
  • GitHub Check: Pack & Upload
  • GitHub Check: OSV Scanner PR
  • GitHub Check: actionlint
🧰 Additional context used
📓 Path-based instructions (7)
packages/postgres/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (packages/postgres/AGENTS.md)

packages/postgres/**/*.{ts,tsx,js,jsx}: Use tagged template literals as the primary query interface when using the postgres client
Use StructuredError from @agentuity/core for error handling
Handle ConnectionClosedError and retryable errors using error instanceof checks and isRetryableError utility
Set preconnect: true in config to establish TCP connection immediately, otherwise connections are established lazily on first query
Use shutdownAll, getClientCount, and hasActiveClients utilities from the global registry for coordinated client lifecycle management

Files:

  • packages/postgres/test/pool-compat.test.ts
  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
packages/postgres/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/postgres/AGENTS.md)

Maintain full TypeScript support with type safety throughout the postgres client

Files:

  • packages/postgres/test/pool-compat.test.ts
  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
packages/postgres/**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (packages/postgres/AGENTS.md)

Tests require a running PostgreSQL instance and should use @agentuity/test-utils for mocking

Files:

  • packages/postgres/test/pool-compat.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Run bun run format using Biome with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/postgres/test/pool-compat.test.ts
  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript in strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/postgres/test/pool-compat.test.ts
  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
**/packages/*/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/packages/*/test/**/*.{ts,tsx}: Place tests in test/ folder parallel to src/ directory, never inside src/ or under __tests__/
Import from ../src/ in test files
Use @agentuity/test-utils for shared mocks in tests

Files:

  • packages/postgres/test/pool-compat.test.ts
packages/postgres/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/postgres/AGENTS.md)

Implement exponential backoff with jitter for connection reconnection attempts

Files:

  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
🧠 Learnings (2)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/postgres/test/pool-compat.test.ts
  • packages/postgres/src/types.ts
  • packages/postgres/src/pool.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.

Applied to files:

  • packages/postgres/test/pool-compat.test.ts
🔇 Additional comments (5)
packages/postgres/src/pool.ts (3)

4-4: LGTM!


13-17: LGTM!


487-489: LGTM!

packages/postgres/src/types.ts (1)

388-392: LGTM!

packages/postgres/test/pool-compat.test.ts (1)

136-169: LGTM!

Comment thread packages/postgres/src/pool.ts
lastDisconnectedAt is pool-level disconnect state; idle client drops are
self-healed by pg.Pool and must not update it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jhaynie
jhaynie merged commit a396745 into main Jul 20, 2026
27 of 28 checks passed
@jhaynie
jhaynie deleted the fix/postgres-pool-idle-error branch July 20, 2026 20:53
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