pitcheye.dev← All 30 rules
severity: errorpack: dbv1.0 core

db/postgres-js-prepare-true-with-pooler

postgres.js against a pooler without `prepare: false`

npx @pitcheye/check . --pack db

whyItBreaks

postgres.js prepares statements by default. A transaction pooler multiplexes backends, so a prepared statement created on one connection is missing on the next — you get `prepared statement "s1" already exists` or `does not exist` under load, and only under load.

✖ Bad — triggers errorfixtures/db-postgres-js-prepare-true-with-pooler/bad
const client = postgres('postgresql://…pooler.supabase.com:6543/postgres', { max: 10 });
✓ Good — passes checkfixtures/db-postgres-js-prepare-true-with-pooler/good
const client = postgres('postgresql://…pooler.supabase.com:6543/postgres', { max: 10, prepare: false });

suggestedFix

Pass `{ prepare: false }` in the postgres.js options whenever the connection string is pooled.

explain_rule({"db/postgres-js-prepare-true-with-pooler"})

Agent & MCP JSON output contract

{
  "ruleId": "db/postgres-js-prepare-true-with-pooler",
  "pack": "db",
  "severity": "error",
  "file": "apps/web/src/app/api/health/route.ts",
  "line": 6,
  "message": "postgres(<pooler url>, opts) where opts does not set prepare: false",
  "whyItBreaks": "postgres.js prepares statements by default. A transaction pooler multiplexes backends, so a prepared statement created on one connection is missing on the next — you get `prepared statement \"s1\" already exists` or `does not exist` under load, and only under load.",
  "suggestedFix": "Pass `{ prepare: false }` in the postgres.js options whenever the connection string is pooled.",
  "docsUrl": "https://pitcheye.dev/rules/db-postgres-js-prepare-true-with-pooler"
}

Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/db-postgres-js-prepare-true-with-pooler

raw markdown
# db/postgres-js-prepare-true-with-pooler

- **severity:** error
- **pack:** db
- **docs:** https://pitcheye.dev/rules/db-postgres-js-prepare-true-with-pooler

## whyItBreaks

postgres.js prepares statements by default. A transaction pooler multiplexes backends, so a prepared statement created on one connection is missing on the next — you get `prepared statement "s1" already exists` or `does not exist` under load, and only under load.

## bad

```ts
const client = postgres('postgresql://…pooler.supabase.com:6543/postgres', { max: 10 });
```

## good

```ts
const client = postgres('postgresql://…pooler.supabase.com:6543/postgres', { max: 10, prepare: false });
```

## suggestedFix

Pass `{ prepare: false }` in the postgres.js options whenever the connection string is pooled.

## commands

```bash
npx @pitcheye/check . --pack db
```

```json
{"tool":"explain_rule","arguments":{"ruleId":"db/postgres-js-prepare-true-with-pooler"}}
```
← db/neon-pooler-in-migrationsBack to rule catalogdb/neon-http-multi-statement-tx →