fix(postgres): enforce query timeout on server - #415
Merged
tianzhou merged 1 commit intoSep 2, 2026
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation addresses backend query leakage and includes focused configuration and integration coverage.
Pull request overview
Adds server-side PostgreSQL query cancellation while retaining a delayed client-side fallback.
Changes:
- Maps
query_timeoutto PostgreSQLstatement_timeout. - Adds unit and integration coverage for cancellation and connection reuse.
File summaries
| File | Description |
|---|---|
src/connectors/postgres/index.ts |
Configures server and client timeouts. |
src/connectors/__tests__/postgres.integration.test.ts |
Verifies cancellation and connection reuse. |
src/connectors/__tests__/dsn-parser.test.ts |
Verifies timeout configuration values. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tianzhou
approved these changes
Sep 2, 2026
tianzhou
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks for the contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
query_timeoutto the server-sidestatement_timeoutpg_stat_activityand the connection remains reusableWhy
node-postgres
query_timeoutonly stops the client from waiting. The PostgreSQL backend can continue executing the abandoned statement, which is the same failure class reported for MySQL in #384 and fixed in #386.Using
statement_timeoutas a connection startup parameter preserves the existing per-source TOML configuration and requires no role-level or database-level setting. The slightly longer client timeout remains a fallback while allowing the server cancellation response to arrive first.Testing
pnpm run test:unit— 989 passedpnpm exec vitest run --project integration src/connectors/__tests__/postgres.integration.test.ts— 52 passedpnpm run build— passed