Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

feat(sql-runtime): add callback-based transaction API - #346

Merged
aqrln merged 3 commits into
mainfrom
transaction-api-m1
Apr 23, 2026
Merged

aqrln merged 3 commits into
mainfrom
transaction-api-m1

Conversation

@aqrln

@aqrln aqrln commented Apr 15, 2026 •

Copy link
Copy Markdown
Member

PR Stack: Transaction API

PR Description Base
#345 📄 Spec, plan, and ADR main
#346 (this) ⚙️ Core transaction runtime + db.transaction() + tx.sql #345
#347 🔗 Wire tx.orm into transactions #346

Refs: https://linear.app/prisma-company/issue/TML-1912/orm-transaction-support
Closes: https://linear.app/prisma-company/issue/TML-2161/orm-sql-dsl-transaction-interop


Summary

Implements Milestone 1 of the transaction API: the core withTransaction helper in sql-runtime (target-agnostic) and the db.transaction() surface on PostgresClient with tx.sql support.

Implementation

withTransaction(runtime, fn) — @prisma-next/sql-runtime

A target-agnostic helper that manages the full transaction lifecycle:

  1. Acquires a connection from the pool → starts a transaction
  2. Runs the user callback with a guarded TransactionContext
  3. On success: sets invalidated = true → commits → releases connection
  4. On error: sets invalidated = true → rolls back → releases connection → re-throws

Safety features:

  • Pre-execution guard — calling tx.execute() after the transaction ends throws RUNTIME.TRANSACTION_CLOSED
  • Iteration guard — a guarded AsyncGenerator wraps every result; consuming rows post-commit throws the same error per-yield
  • Rollback failure wrapping — if rollback itself fails, produces RUNTIME.TRANSACTION_ROLLBACK_FAILED with the original error as .cause

PostgresClient.transaction() + PostgresTransactionContext

export interface PostgresTransactionContext<TContract extends Contract<SqlStorage>>
  extends TransactionContext {
  readonly sql: Db<TContract>;
}

db.transaction(fn) delegates to withTransaction, attaching a fresh Db<TContract> SQL builder as tx.sql. Lazy-initializes the runtime on first call (same as connect() / runtime()).

New public exports from @prisma-next/sql-runtime

  • TransactionContext (type)
  • RuntimeConnection, RuntimeTransaction, RuntimeQueryable (types — previously internal)
  • withTransaction (function)

Tests

Unit tests — withTransaction (12 tests)

Test Covers
commits on successful callback and returns the result Happy path
rolls back on callback error and re-throws Error path
releases connection after commit Cleanup on success
releases connection after rollback Cleanup on failure
propagates commit failure COMMIT throws
forwards the callback return value Complex return type
executes queries against the transaction Routing to transaction scope
throws on execute after commit (invalidation) Post-commit guard
throws on iteration of escaped AsyncIterableResult after commit Iteration guard
sets invalidated flag after commit Flag transition
wraps original error when rollback fails Double-fault handling
sets invalidated flag after rollback Flag on error path
releases connection independently across sequential transactions 3 sequential txns

Unit tests — Postgres (3 tests)

  • transaction() delegates to withTransaction with the lazy runtime
  • transaction() provides sql on the transaction context
  • transaction() lazily creates runtime before connect()

Type-level tests (3 tests)

  • Transaction context does not expose a transaction method (no nesting)
  • db.transaction() infers callback return type correctly
  • tx.sql has the same type as db.sql

E2E tests against real Postgres (5 tests)

  • Commits both writes atomically (two INSERTs visible after commit)
  • Rolls back all writes on error (0 rows after throw)
  • Forwards callback return value after commit
  • Collects returned stream before commit (PromiseLike auto-drain)
  • Rejects escaped AsyncIterableResult consumed after commit

Key design decisions

  • Callback-scoped (RAII-style) — guaranteed cleanup, no dangling transactions
  • Invalidation over buffering — consistent lazy execute() semantics everywhere (ADR 187)
  • Structured error codes — RUNTIME.TRANSACTION_CLOSED, RUNTIME.TRANSACTION_ROLLBACK_FAILED
  • Layered composition — core helper in sql-runtime, adapter adds tx.sql surface
  • No nested transactions by type design — PostgresTransactionContext omits transaction, enforced at compile time
  • PromiseLike<R> callback return — auto-drains AsyncIterableResult when returned directly

Files changed

  • packages/2-sql/5-runtime/src/sql-runtime.ts — withTransaction, TransactionContext
  • packages/2-sql/5-runtime/src/exports/index.ts — new exports
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts — 12 unit tests
  • packages/3-extensions/postgres/src/runtime/postgres.ts — db.transaction(), PostgresTransactionContext
  • packages/3-extensions/postgres/test/postgres.test.ts — 3 unit tests
  • packages/3-extensions/postgres/test/transaction.types.test-d.ts — 3 type tests (new)
  • test/e2e/framework/test/transaction.test.ts — 5 e2e tests (new)
  • projects/orm-client-transaction-api/{plan,spec}.md — mark M1 tasks done

Summary by CodeRabbit

  • New Features

    • Added a managed transaction helper for safe commit/rollback and atomic multi-operation workflows.
    • Transactions now provide an invalidated flag and enforce no-usage after completion.
    • Postgres client exposes a transaction method returning a transaction-scoped DB context.
    • Connection lifecycle: added destroy() for safer teardown and improved driver cleanup semantics.
  • Tests

    • Added unit, type-level, and E2E tests covering commit/rollback, error-wrapping, invalidation, destroy/release behavior, and lifecycle edge cases.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds transactional APIs: RuntimeConnection.destroy, TransactionContext (with invalidation), a withTransaction helper implementing acquire/commit/rollback/destroy semantics, Postgres client transaction integration, and tests (unit, type, and E2E) covering lifecycle and error flows.

Changes

Cohort / File(s) Summary
SQL Runtime Core
packages/2-sql/5-runtime/src/sql-runtime.ts, packages/2-sql/5-runtime/src/exports/index.ts
Added withTransaction(...) and TransactionContext (with invalidated), added RuntimeConnection.destroy(reason?), implemented transaction lifecycle (commit/rollback, error wrapping, eviction/destroy), and re-exported new types and withTransaction.
SQL Runtime Tests
packages/2-sql/5-runtime/test/sql-runtime.test.ts
Expanded driver mock spies and added comprehensive tests for withTransaction: commit/rollback paths, error-wrapping codes, destroy vs release semantics, invalidation (including async-iteration), and lifecycle counts.
Framework Runtime Core
packages/1-framework/4-runtime/runtime-executor/src/runtime-core.ts
Added RuntimeConnection.destroy(reason?) and mirrored DriverConnection.destroy(reason?) to expose destroy lifecycle at runtime-core level.
Relational Core Driver Types & Tests
packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts, .../test/ast/driver-types.*
Added SqlConnection.destroy(reason?) signature and updated docs; updated test mocks to include destroy and clarify release() vs destroy() semantics.
Postgres Extension
packages/3-extensions/postgres/src/runtime/postgres.ts, packages/3-extensions/postgres/test/*, packages/3-extensions/postgres/test/transaction.types.test-d.ts
Added PostgresTransactionContext<T> (extends TransactionContext with sql) and PostgresClient.transaction() implemented via withTransaction; added runtime and compile-time tests verifying delegation and typings.
Driver: Postgres
packages/3-targets/7-drivers/postgres/src/postgres-driver.ts, packages/3-targets/7-drivers/postgres/src/exports/runtime.ts, packages/3-targets/7-drivers/postgres/test/*.test.ts
Wrapped acquired connections, added connection destroy() handling (calls pool/client release or client.end and invokes onDestroy), ensured release clears destroy callbacks, refactored close flow, and added tests for destroy behavior, state transitions, and concurrency invariants.
Driver: Sqlite
packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts, packages/3-targets/7-drivers/sqlite/test/sqlite-driver.test.ts
Exported SqliteConnectionImpl, moved teardown logic into destroy(reason?), made release() delegate to destroy(), and added tests for close/retry and error propagation.
E2E Tests
test/e2e/framework/test/transaction.test.ts
New E2E suite validating atomic commits, rollback-on-error, return forwarding, materialization of query results after commit, and invalidation of escaped async-iterable results.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Runtime as Runtime
    participant DriverConn as Driver Connection
    participant TxCtx as TransactionContext
    participant Callback as Callback

    Caller->>Runtime: withTransaction(runtime, fn)
    activate Runtime
    Runtime->>DriverConn: acquireConnection()
    activate DriverConn
    DriverConn-->>Runtime: connection
    Runtime->>DriverConn: beginTransaction()
    activate TxCtx
    Runtime->>Callback: fn(txCtx)
    activate Callback
    Callback->>TxCtx: tx.execute(...) / iterate(...)
    TxCtx-->>Callback: results / async iterable
    Callback-->>Runtime: return or throw
    deactivate Callback
    alt success
        Runtime->>DriverConn: commit()
        DriverConn-->>Runtime: commit ok
    else failure
        Runtime->>DriverConn: rollback()
        DriverConn-->>Runtime: rollback ok / rollback error
    end
    alt connection suspect or teardown failed
        Runtime->>DriverConn: destroy(reason)
    else normal
        Runtime->>DriverConn: release()
    end
    deactivate TxCtx
    deactivate DriverConn
    deactivate Runtime
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibbled through transactions, cautious and spry,
Began with a lease, committed a sigh,
If errors then tumble, I roll them away,
Or evict a connection to sleep for the day,
A rabbit's small patch—safe, tidy, and spry.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(sql-runtime): add callback-based transaction API' directly and clearly describes the main change—introducing a callback-based transaction API to the sql-runtime package, which is the primary focus of this PR.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch transaction-api-m1

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

@pkg-pr-new

pkg-pr-new Bot commented Apr 15, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@346

@prisma-next/family-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-mongo@346

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@346

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@346

@prisma-next/middleware-telemetry

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/middleware-telemetry@346

@prisma-next/mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo@346

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@346

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@346

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@346

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@346

@prisma-next/sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sqlite@346

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@346

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@346

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@346

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@346

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@346

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@346

@prisma-next/errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/errors@346

@prisma-next/framework-components

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/framework-components@346

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@346

@prisma-next/ts-render

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ts-render@346

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@346

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@346

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@346

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@346

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@346

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@346

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@346

prisma-next

npm i https://pkg.pr.new/prisma/prisma-next@346

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@346

@prisma-next/runtime-executor

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/runtime-executor@346

@prisma-next/mongo-codec

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-codec@346

@prisma-next/mongo-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract@346

@prisma-next/mongo-value

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-value@346

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-psl@346

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-ts@346

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-emitter@346

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-schema-ir@346

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-ast@346

@prisma-next/mongo-orm

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-orm@346

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-builder@346

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-lowering@346

@prisma-next/mongo-wire

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-wire@346

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@346

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@346

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@346

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@346

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@346

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@346

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@346

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@346

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@346

@prisma-next/sql-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder@346

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@346

@prisma-next/target-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-sqlite@346

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@346

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-sqlite@346

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@346

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-sqlite@346

commit: bbe5b7f

@aqrln
aqrln marked this pull request as ready for review April 15, 2026 20:04
aqrln added a commit that referenced this pull request Apr 22, 2026
## PR Stack: Transaction API

| PR | Description | Base |
|---|---|---|
| **#345** (this) | 📄 Spec, plan, and ADR | `main` |
| #346 | ⚙️ Core transaction runtime + `db.transaction()` + `tx.sql` |
`#345` |
| #347 | 🔗 Wire `tx.orm` into transactions | `#346` |

Part of
https://linear.app/prisma-company/issue/TML-1912/orm-transaction-support

---

## Summary

Adds the foundational design documents for the **ORM Client Transaction
API** (`db.transaction(callback)`):

- **Spec** — full feature specification for `db.transaction()` on
`PostgresClient`
- **Plan** — 4-milestone delivery plan with acceptance criteria
traceability matrix
- **ADR 187** — architecture decision on how transaction-scoped streams
handle post-commit consumption

## Spec highlights

The API follows a **callback-scoped** pattern — no dangling
transactions, guaranteed cleanup:

```ts
await db.transaction(async (tx) => {
  await tx.orm.account.where({ id: fromId }).update({ balance: fromBalance - amount });
  const plan = tx.sql.from(tables.auditLog).insert({ action: 'transfer', amount }).build();
  await tx.execute(plan);
});
```

The transaction context exposes three surfaces:
- `tx.orm` — full ORM collection API bound to the transaction connection
- `tx.sql` — typed SQL builder (`Db<TContract>`) bound to the same
connection
- `tx.execute(plan)` — execute a built plan directly

Explicit **non-goals**: configurable isolation levels,
savepoints/nesting, automatic retry, interactive begin/commit/rollback
handle, timeout, MongoDB support.

## Plan

| Milestone | Scope | Status |
|---|---|---|
| M1 — Transaction runtime plumbing | `withTransaction` helper,
`db.transaction()`, `tx.sql`, unit + e2e tests | ✅ Done |
| M2 — ORM integration | `tx.orm` wiring, `withMutationScope` fallback,
nested-mutation e2e tests | ✅ Done |
| M3 — Type safety & edge cases | Type-level tests, `PromiseLike` drain,
post-commit invalidation, lazy connect | ☐ Pending |
| M4 — Close-out | Acceptance criteria verification, doc finalization,
project cleanup | ☐ Pending |

## ADR 187: Transaction-scoped streams use invalidation, not buffering

**Decision**: When a transaction ends, the scoped `RuntimeQueryable`
sets an `invalidated` flag. Any `AsyncIterableResult` consumed after
that point throws a clear error rather than hitting a released
connection.

**Rejected alternatives**: eager buffering (silently changes semantics),
type-level prevention (breaks inference), pre-commit tracking (rejects
valid patterns), do nothing (confusing errors).

The ADR includes a wire-protocol safety analysis confirming that
unconsumed result streams cannot hide database errors or cause an
incorrect COMMIT in Postgres.

## Files

- `projects/orm-client-transaction-api/spec.md` (new)
- `projects/orm-client-transaction-api/plan.md` (new)
- `docs/architecture docs/adrs/ADR 187 - Transaction-scoped streams use
invalidation not buffering.md` (new)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added guidance on transaction-scoped streaming behavior, including
error handling for results accessed outside the transaction scope and
best practices for consuming results within transactions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Base automatically changed from transaction-api-spec to main April 22, 2026 10:17
An error occurred while trying to automatically change base from transaction-api-spec to main April 22, 2026 10:17
@aqrln
aqrln force-pushed the transaction-api-m1 branch from f4da1a0 to f189362 Compare April 22, 2026 10:18

@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

🧹 Nitpick comments (2)
test/e2e/framework/test/transaction.test.ts (2)

12-12: Use shared timeout helpers instead of hardcoded values.

♻️ Proposed fix
+import { timeouts } from '@prisma-next/test-utils';
+
 // ...
 
-describe('transaction E2E', { timeout: 30000 }, () => {
+describe('transaction E2E', { timeout: timeouts.databaseOperation }, () => {

Based on learnings: "use prisma-next/test-utils timeout helpers... Use timeouts.databaseOperation for database operation scenarios."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/framework/test/transaction.test.ts` at line 12, Replace the
hardcoded timeout 30000 in the describe call for "transaction E2E" with the
shared helper timeouts.databaseOperation from prisma-next/test-utils: import the
timeouts symbol (e.g., add "import { timeouts } from 'prisma-next/test-utils'")
if not present, then update describe('transaction E2E', { timeout: 30000 }, ...)
to use { timeout: timeouts.databaseOperation } so the test uses the shared
timeout constant.

1-2: Prefer pathe over node:path for cross-platform consistency.

♻️ Proposed fix
-import { dirname, resolve } from 'node:path';
+import { dirname, resolve } from 'pathe';

Based on learnings: "In the prisma/prisma-next repo, prefer using pathe over Node's built-in node:path."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/framework/test/transaction.test.ts` around lines 1 - 2, Replace
usage of Node built-ins with pathe: remove imports of dirname and resolve from
'node:path' and fileURLToPath from 'node:url' and instead import dirname,
resolve, and fromFileUrl from 'pathe' (used where fileURLToPath was used).
Update any call sites that used fileURLToPath(fileURL) to fromFileUrl(fileURL)
so the test uses pathe's cross-platform path helpers (refer to imports at the
top of the file).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/3-extensions/postgres/src/runtime/postgres.ts`:
- Around line 251-260: The spread of txCtx in transaction(...) copies the
current value of the invalidated getter (losing the live getter), so replace the
spread with an object that preserves txCtx as prototype (e.g.,
Object.create(txCtx)) then assign/override the sql property; i.e., construct tx
via Object.create(txCtx) and set tx.sql = txSql so PostgresTransactionContext
keeps the original invalidated getter and other live accessors while still using
the new sql instance for this transaction.

---

Nitpick comments:
In `@test/e2e/framework/test/transaction.test.ts`:
- Line 12: Replace the hardcoded timeout 30000 in the describe call for
"transaction E2E" with the shared helper timeouts.databaseOperation from
prisma-next/test-utils: import the timeouts symbol (e.g., add "import { timeouts
} from 'prisma-next/test-utils'") if not present, then update
describe('transaction E2E', { timeout: 30000 }, ...) to use { timeout:
timeouts.databaseOperation } so the test uses the shared timeout constant.
- Around line 1-2: Replace usage of Node built-ins with pathe: remove imports of
dirname and resolve from 'node:path' and fileURLToPath from 'node:url' and
instead import dirname, resolve, and fromFileUrl from 'pathe' (used where
fileURLToPath was used). Update any call sites that used fileURLToPath(fileURL)
to fromFileUrl(fileURL) so the test uses pathe's cross-platform path helpers
(refer to imports at the top of the file).
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 1e64dbcf-5089-47f8-8eec-629aa5e807f3

📥 Commits

Reviewing files that changed from the base of the PR and between f1f0f64 and f189362.

⛔ Files ignored due to path filters (2)
  • projects/orm-client-transaction-api/plan.md is excluded by !projects/**
  • projects/orm-client-transaction-api/spec.md is excluded by !projects/**
📒 Files selected for processing (7)
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/sql-runtime.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-extensions/postgres/test/postgres.test.ts
  • packages/3-extensions/postgres/test/transaction.types.test-d.ts
  • test/e2e/framework/test/transaction.test.ts

@aqrln
aqrln force-pushed the transaction-api-m1 branch from f189362 to de5e736 Compare April 22, 2026 10:34

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts (1)

120-132: ⚠️ Potential issue | 🟠 Major

Keep SqliteDriver.close() retryable after delegated destroy() failures.

With release() now delegating to destroy(), SqliteDriver.close() in this same file becomes incorrect: it marks the driver closed before awaiting conn.release(). If DatabaseSync.close() throws, the handle stays open, but every later driver.close() call is a no-op because the state is already 'closed'. That strands the connection and makes the new retryable-cleanup contract unreachable through the driver.

Proposed fix
   async close(): Promise<void> {
     if (this.#state.kind !== 'connected') return;
     const { conn } = this.#state;
-    this.#state = { kind: 'closed' };
     await conn.release();
+    if (this.#state.kind === 'connected' && this.#state.conn === conn) {
+      this.#state = { kind: 'closed' };
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts` around lines 120 -
132, SqliteDriver.close() currently marks the driver closed before awaiting
conn.release(), which prevents retries if destroy()/DatabaseSync.close() throws;
change close() so it first awaits conn.release() (which delegates to
destroy()/#db.close()), and only set the driver's state to 'closed' after
release completes successfully; if conn.release() throws, rethrow the error and
leave the state as not-closed so subsequent close() calls remain retryable.
Update logic referencing SqliteDriver.close(), release(), destroy(), and
DatabaseSync.close() accordingly so destroy() still throws normalized errors but
does not flip driver state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/3-targets/7-drivers/postgres/src/postgres-driver.ts`:
- Around line 348-359: The teardown passed to PostgresConnectionImpl currently
calls releaseLease() before awaiting this.close(), which allows
acquireConnection() to race in and reuse the same direct client while the socket
is still being closed; change the teardown so it awaits driver shutdown (call
and await this.close(), which must wait for direct client .end() and set
`#closed`) before calling releaseLease(), ensuring the lease remains held until
the socket is fully closed and preventing acquireConnection() from observing an
intermediate reusable state; reference PostgresConnectionImpl, releaseLease,
this.close, `#connectionMutex` and acquireConnection when making this change.

---

Outside diff comments:
In `@packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts`:
- Around line 120-132: SqliteDriver.close() currently marks the driver closed
before awaiting conn.release(), which prevents retries if
destroy()/DatabaseSync.close() throws; change close() so it first awaits
conn.release() (which delegates to destroy()/#db.close()), and only set the
driver's state to 'closed' after release completes successfully; if
conn.release() throws, rethrow the error and leave the state as not-closed so
subsequent close() calls remain retryable. Update logic referencing
SqliteDriver.close(), release(), destroy(), and DatabaseSync.close() accordingly
so destroy() still throws normalized errors but does not flip driver state.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 4b497fee-c17b-40eb-8431-2546c45c5d39

📥 Commits

Reviewing files that changed from the base of the PR and between de5e736 and 8eecb1e.

📒 Files selected for processing (12)
  • packages/1-framework/4-runtime/runtime-executor/src/runtime-core.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.types.test-d.ts
  • packages/2-sql/5-runtime/src/sql-runtime.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/7-drivers/postgres/src/postgres-driver.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.unbound.test.ts
  • packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts
  • packages/3-targets/7-drivers/sqlite/test/sqlite-driver.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/2-sql/5-runtime/src/sql-runtime.ts

aqrln added 3 commits April 23, 2026 18:27
- Make rollback errors close connections instead of returning them back
  to the pool.
- Attempt rollback on commit failure (similar to what Prisma does).
@aqrln
aqrln force-pushed the transaction-api-m1 branch from ca6cb9e to bbe5b7f Compare April 23, 2026 16:28
@aqrln
aqrln enabled auto-merge (squash) April 23, 2026 16:29

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

🧹 Nitpick comments (3)
packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts (1)

68-68: Keep SqliteConnectionImpl private; expose a factory instead.

Exporting the concrete class widens the module API surface. Prefer a factory returning SqlConnection and keep the class internal.

♻️ Suggested refactor
-export class SqliteConnectionImpl implements SqlConnection {
+class SqliteConnectionImpl implements SqlConnection {
   readonly `#db`: DatabaseSync;
   ...
 }
+
+export function createSqliteConnection(db: DatabaseSync): SqlConnection {
+  return new SqliteConnectionImpl(db);
+}
- import { ..., SqliteConnectionImpl } from '../src/sqlite-driver';
+ import { ..., createSqliteConnection } from '../src/sqlite-driver';

- const connection = new SqliteConnectionImpl(db);
+ const connection = createSqliteConnection(db);
As per coding guidelines: "Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts` at line 68, Remove
the exported concrete class by making SqliteConnectionImpl non-exported (drop
the export) and add an exported factory function (e.g., createSqliteConnection
or sqliteConnectionFactory) that returns the SqlConnection interface; update any
call sites to use the new factory and keep all implementation details inside the
now-internal SqliteConnectionImpl class so the module only exposes SqlConnection
and the factory function.
test/e2e/framework/test/transaction.test.ts (2)

12-12: Use shared timeout helpers instead of hardcoded values.

The hardcoded 30000 timeout should use the shared timeout helper for database operations.

♻️ Suggested fix
+import { timeouts } from '@prisma-next/test-utils';
 ...
-describe('transaction E2E', { timeout: 30000 }, () => {
+describe('transaction E2E', { timeout: timeouts.databaseOperation }, () => {

Based on learnings: "use prisma-next/test-utils timeout helpers—specifically timeouts.databaseOperation for database operation scenarios."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/framework/test/transaction.test.ts` at line 12, Replace the
hardcoded 30000 timeout on the describe('transaction E2E', ...) call with the
shared helper timeouts.databaseOperation from the prisma-next/test-utils
package: import the timeouts symbol (e.g. add an import for timeouts from
'prisma-next/test-utils') and change the describe options to use timeout:
timeouts.databaseOperation so the test uses the shared database operation
timeout constant.

1-2: Prefer pathe over node:path for cross-platform consistency.

Based on learnings, the repo prefers pathe over Node's built-in node:path module for path operations.

♻️ Suggested fix
-import { dirname, resolve } from 'node:path';
-import { fileURLToPath } from 'node:url';
+import { dirname, resolve } from 'pathe';
+import { fileURLToPath } from 'pathe';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/framework/test/transaction.test.ts` around lines 1 - 2, Replace the
node:path import with pathe to ensure cross-platform path handling: change
"import { dirname, resolve } from 'node:path';" to import those same symbols
from 'pathe' (keep using fileURLToPath from 'node:url' as before), and update
any usages of dirname or resolve in this file (e.g., in transaction.test.ts
where dirname, resolve and fileURLToPath are used) to rely on the pathe
implementations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts`:
- Line 68: Remove the exported concrete class by making SqliteConnectionImpl
non-exported (drop the export) and add an exported factory function (e.g.,
createSqliteConnection or sqliteConnectionFactory) that returns the
SqlConnection interface; update any call sites to use the new factory and keep
all implementation details inside the now-internal SqliteConnectionImpl class so
the module only exposes SqlConnection and the factory function.

In `@test/e2e/framework/test/transaction.test.ts`:
- Line 12: Replace the hardcoded 30000 timeout on the describe('transaction
E2E', ...) call with the shared helper timeouts.databaseOperation from the
prisma-next/test-utils package: import the timeouts symbol (e.g. add an import
for timeouts from 'prisma-next/test-utils') and change the describe options to
use timeout: timeouts.databaseOperation so the test uses the shared database
operation timeout constant.
- Around line 1-2: Replace the node:path import with pathe to ensure
cross-platform path handling: change "import { dirname, resolve } from
'node:path';" to import those same symbols from 'pathe' (keep using
fileURLToPath from 'node:url' as before), and update any usages of dirname or
resolve in this file (e.g., in transaction.test.ts where dirname, resolve and
fileURLToPath are used) to rely on the pathe implementations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: a0571693-0276-453c-bd8d-a47fb3d194c9

📥 Commits

Reviewing files that changed from the base of the PR and between 8eecb1e and bbe5b7f.

⛔ Files ignored due to path filters (2)
  • projects/orm-client-transaction-api/plan.md is excluded by !projects/**
  • projects/orm-client-transaction-api/spec.md is excluded by !projects/**
📒 Files selected for processing (17)
  • packages/1-framework/4-runtime/runtime-executor/src/runtime-core.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.types.test-d.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/sql-runtime.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-extensions/postgres/test/postgres.test.ts
  • packages/3-extensions/postgres/test/transaction.types.test-d.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/7-drivers/postgres/src/postgres-driver.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.unbound.test.ts
  • packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts
  • packages/3-targets/7-drivers/sqlite/test/sqlite-driver.test.ts
  • test/e2e/framework/test/transaction.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts

@aqrln
aqrln merged commit a21bf71 into main Apr 23, 2026
22 of 23 checks passed
@aqrln
aqrln deleted the transaction-api-m1 branch April 23, 2026 17:16
aqrln added a commit that referenced this pull request Apr 24, 2026
## PR Stack: Transaction API

| PR | Description | Base |
|---|---|---|
| #345 | 📄 Spec, plan, and ADR | `main` |
| #346 | ⚙️ Core transaction runtime + `db.transaction()` + `tx.sql` |
`#345` |
| **#347** (this) | 🔗 Wire `tx.orm` into transactions | `#346` |

Closes
https://linear.app/prisma-company/issue/TML-1912/orm-transaction-support

---

## Summary

Implements **Milestone 2** of the transaction API: wiring `tx.orm` so
that ORM collections used inside a `db.transaction()` callback execute
against the transaction connection. Also adds relations to the e2e
fixture contract to enable nested-mutation integration tests.

## Implementation

The production change is **surgical** — ~12 lines in a single file.

### `PostgresTransactionContext` gains `orm`

```ts
export interface PostgresTransactionContext<TContract extends Contract<SqlStorage>>
  extends TransactionContext {
  readonly sql: Db<TContract>;
  readonly orm: OrmClient<TContract>;  // ← new
}
```

### Transaction-scoped ORM client construction

Inside `transaction()`, a new `ormBuilder()` creates an ORM client bound
to the transaction's `execute`:

```ts
const txOrm: OrmClient<TContract> = ormBuilder({
  runtime: {
    execute(plan) {
      return txCtx.execute(plan);
    },
  },
  context,
});
```

**Key design decision**: The `runtime` object passed to `ormBuilder`
exposes **only** `execute()` — it deliberately omits `connection()` and
`transaction()`. This ensures `withMutationScope` in the mutation
executor naturally falls through to direct scope reuse instead of
attempting a nested transaction. **Zero changes to the mutation executor
were needed.**

## Tests

### Unit tests (4 new)

| Test | Location | Covers |
|---|---|---|
| `transaction()` provides `orm` on the tx context | `postgres.test.ts`
| `tx.orm` is the transaction-scoped proxy |
| `tx.orm` has the same type as `db.orm` | `transaction.types.test-d.ts`
| Compile-time type equivalence |
| `executeNestedCreateMutation()` reuses scope when runtime lacks
`transaction` | `mutation-executor.test.ts` | Fast-path: direct
`execute` on the transaction runtime |
| `withMutationScope` reuses runtime when no `transaction` or
`connection` exists | `mutation-executor.test.ts` | Scope reuse without
nested transaction |

### E2E integration tests (5 new — real PGlite database)

| Test | Covers |
|---|---|
| ORM create with nested relation mutation commits atomically |
`tx.orm.Post.create()` with nested `author: (r) => r.create(...)` — both
rows exist |
| ORM create with nested relation mutation rolls back on throw | Same
nested create + throw — neither row exists |
| ORM write then read within the same transaction |
Read-your-own-writes: `create()` then `where().first()` sees the row |
| Multiple ORM operations in a transaction are atomic | Two posts + user
all commit together |
| Multiple ORM operations roll back together on throw | Same operations
+ throw — nothing persists |

## E2E fixture contract changes

The fixture contract gained **relations** across all three models to
enable nested-mutation tests:

| Model | Relation | Type | Join |
|---|---|---|---|
| `User` | `posts` | `1:N` → `Post` | `User.id` → `Post.userId` |
| `Post` | `author` | `N:1` → `User` | `Post.userId` → `User.id` |
| `Post` | `comments` | `1:N` → `Comment` | `Post.id` → `Comment.postId`
|
| `Comment` | `post` | `N:1` → `Post` | `Comment.postId` → `Post.id` |

The contract definition was refactored to compose models with
`rel.belongsTo()` / `rel.hasMany()` before passing to `defineContract`,
using lazy refs (`() => Comment`) for circular relations.

## Design patterns

- **Capability elision for scope reuse** — the transaction-scoped
runtime is a minimal `{ execute }` object; omitting `transaction()` /
`connection()` makes `withMutationScope` fall through naturally
- **Interface segregation** — `RuntimeQueryable` passed to `ormBuilder`
is a narrowed shape, preventing accidental nested-transaction creation
- **Warm-up pattern for PGlite** — e2e helper calls
`db.orm.User.first()` before entering transactions to force contract
verification (which needs its own connection) outside the transaction,
avoiding deadlock on single-connection PGlite

## Files changed

- `packages/3-extensions/postgres/src/runtime/postgres.ts` — add
`tx.orm` construction
- `packages/3-extensions/postgres/test/postgres.test.ts` — 1 unit test
- `packages/3-extensions/postgres/test/transaction.types.test-d.ts` — 1
type test
- `packages/3-extensions/sql-orm-client/test/mutation-executor.test.ts`
— 2 unit tests
- `test/e2e/framework/test/transaction-orm.test.ts` — 5 e2e tests (new)
- `test/e2e/framework/test/fixtures/contract.ts` — add relations to
fixture
- `test/e2e/framework/test/fixtures/generated/contract.{d.ts,json}` —
regenerated
- `test/e2e/framework/package.json` + `pnpm-lock.yaml` — add
`@prisma-next/postgres` dev dep
- `projects/orm-client-transaction-api/{plan,spec}.md` — mark M2 tasks
done


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* ORM client is now available inside transaction contexts, allowing ORM
calls to participate in the same transactions as SQL.

* **Tests**
* Added e2e transaction integration tests covering atomic commits,
rollbacks, nested relation mutations, and read-your-own-writes
semantics.
* Added type-safety checks and unit tests for mutation execution scope
and transaction-scoped ORM behavior.

* **Chores**
* Test framework dependency updated to include the Postgres extension;
test fixtures reorganized for relation modeling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants