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

db/neon-http-multi-statement-tx

`db.transaction()` on the Neon HTTP driver

npx @pitcheye/check . --pack db

whyItBreaks

The Neon HTTP driver sends one statement per request and cannot hold a session, so `transaction()` cannot actually begin/commit across statements. Statements run outside the transaction and a failure mid-way leaves half-written data — atomically broken money paths.

✖ Bad — triggers errorfixtures/db-neon-http-multi-statement-tx/bad
const db = drizzle(neon(url));
await db.transaction(async (tx) => { … });
✓ Good — passes checkfixtures/db-neon-http-multi-statement-tx/good
const db = drizzle(new Pool({ connectionString: url })); // drizzle-orm/neon-serverless
await db.transaction(async (tx) => { … });

suggestedFix

Use `drizzle-orm/neon-serverless` with a `Pool` (the WebSocket driver) wherever you need transactions, or send the whole unit as one SQL statement.

explain_rule({"db/neon-http-multi-statement-tx"})

Agent & MCP JSON output contract

{
  "ruleId": "db/neon-http-multi-statement-tx",
  "pack": "db",
  "severity": "error",
  "file": "apps/web/src/app/api/health/route.ts",
  "line": 6,
  "message": "drizzle-orm/neon-http imported and `.transaction()` called",
  "whyItBreaks": "The Neon HTTP driver sends one statement per request and cannot hold a session, so `transaction()` cannot actually begin/commit across statements. Statements run outside the transaction and a failure mid-way leaves half-written data — atomically broken money paths.",
  "suggestedFix": "Use `drizzle-orm/neon-serverless` with a `Pool` (the WebSocket driver) wherever you need transactions, or send the whole unit as one SQL statement.",
  "docsUrl": "https://pitcheye.dev/rules/db-neon-http-multi-statement-tx"
}

Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/db-neon-http-multi-statement-tx

raw markdown
# db/neon-http-multi-statement-tx

- **severity:** error
- **pack:** db
- **docs:** https://pitcheye.dev/rules/db-neon-http-multi-statement-tx

## whyItBreaks

The Neon HTTP driver sends one statement per request and cannot hold a session, so `transaction()` cannot actually begin/commit across statements. Statements run outside the transaction and a failure mid-way leaves half-written data — atomically broken money paths.

## bad

```ts
const db = drizzle(neon(url));
await db.transaction(async (tx) => { … });
```

## good

```ts
const db = drizzle(new Pool({ connectionString: url })); // drizzle-orm/neon-serverless
await db.transaction(async (tx) => { … });
```

## suggestedFix

Use `drizzle-orm/neon-serverless` with a `Pool` (the WebSocket driver) wherever you need transactions, or send the whole unit as one SQL statement.

## commands

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

```json
{"tool":"explain_rule","arguments":{"ruleId":"db/neon-http-multi-statement-tx"}}
```
← db/postgres-js-prepare-true-with-poolerBack to rule catalog