severity: errorpack: dbv1.0 core
db/shared-client-max-one
Shared client configured with `max: 1`
npx @pitcheye/check . --pack dbwhyItBreaks
postgres.js DESTROYS a connection when a query rejects, so with a ceiling of one the next query waits for a connection that will never come back — the process hangs with no error. Even without a rejection it serialises every query in the app behind a single socket.
✖ Bad — triggers errorfixtures/db-shared-client-max-one/bad
const client = postgres(url, { max: 1 });✓ Good — passes checkfixtures/db-shared-client-max-one/good
const client = postgres(url, { max: 10, prepare: false });suggestedFix
Set `max` to a real concurrency budget (typically 5–10 per instance) and keep a single module-level client.
explain_rule({"db/shared-client-max-one"})Agent & MCP JSON output contract
{
"ruleId": "db/shared-client-max-one",
"pack": "db",
"severity": "error",
"file": "apps/web/src/app/api/health/route.ts",
"line": 6,
"message": "a module-level postgres()/Pool with `max: 1` outside migrations and scripts",
"whyItBreaks": "postgres.js DESTROYS a connection when a query rejects, so with a ceiling of one the next query waits for a connection that will never come back — the process hangs with no error. Even without a rejection it serialises every query in the app behind a single socket.",
"suggestedFix": "Set `max` to a real concurrency budget (typically 5–10 per instance) and keep a single module-level client.",
"docsUrl": "https://pitcheye.dev/rules/db-shared-client-max-one"
}Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/db-shared-client-max-one
raw markdown
# db/shared-client-max-one
- **severity:** error
- **pack:** db
- **docs:** https://pitcheye.dev/rules/db-shared-client-max-one
## whyItBreaks
postgres.js DESTROYS a connection when a query rejects, so with a ceiling of one the next query waits for a connection that will never come back — the process hangs with no error. Even without a rejection it serialises every query in the app behind a single socket.
## bad
```ts
const client = postgres(url, { max: 1 });
```
## good
```ts
const client = postgres(url, { max: 10, prepare: false });
```
## suggestedFix
Set `max` to a real concurrency budget (typically 5–10 per instance) and keep a single module-level client.
## commands
```bash
npx @pitcheye/check . --pack db
```
```json
{"tool":"explain_rule","arguments":{"ruleId":"db/shared-client-max-one"}}
```