Skip to content

Fix 29271#29303

Merged
jacek-prisma merged 3 commits into
prisma:mainfrom
yazan-abu-obaideh:fix-29271
Apr 9, 2026
Merged

Fix 29271#29303
jacek-prisma merged 3 commits into
prisma:mainfrom
yazan-abu-obaideh:fix-29271

Conversation

@yazan-abu-obaideh
Copy link
Copy Markdown
Contributor

@yazan-abu-obaideh yazan-abu-obaideh commented Mar 5, 2026

Closes #29271

Summary by CodeRabbit

  • New Features

    • The $transaction batching path now accepts a single optional options object exposing maxWait and timeout, and (when applicable) isolationLevel.
    • Public types and overloads for batch transactions were updated so the consolidated options shape is always available across client APIs.
  • Tests

    • Added a functional test validating batching timeout override behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c0b62bba-5013-422d-99df-4615fff7affc

📥 Commits

Reviewing files that changed from the base of the PR and between 1f35e99 and bd52138.

📒 Files selected for processing (1)
  • packages/client/tests/functional/interactive-transactions/tests.ts

Walkthrough

Adds optional maxWait and timeout to batch transaction types and runtime, and consolidates the generated client batching $transaction overload to always accept a single optional inline options object (which may include isolationLevel when available).

Changes

Cohort / File(s) Summary
Client Generators
packages/client-generator-js/src/TSClient/PrismaClient.ts, packages/client-generator-ts/src/TSClient/PrismaClient.ts
Unifies the batching $transaction signature to always include one optional options?: { maxWait?: number; timeout?: number; isolationLevel?: Prisma.TransactionIsolationLevel }, adding isolationLevel to that object only when the enum exists.
Type Definitions
packages/client/src/runtime/core/engines/common/Engine.ts, packages/client/src/runtime/core/request/PrismaPromise.ts, packages/client/src/runtime/core/types/exported/Extensions.ts
Adds maxWait?: number and timeout?: number to batch transaction types and updates the $transaction overload to accept these timing options alongside isolationLevel.
Runtime Implementation
packages/client/src/runtime/RequestHandler.ts, packages/client/src/runtime/core/engines/client/ClientEngine.ts, packages/client/src/runtime/getPrismaClient.ts
Threads maxWait and timeout through transaction construction and engine start logic, merging these with config defaults when initiating batch transactions.
Tests
packages/client/tests/functional/interactive-transactions/tests.ts
Adds a functional test batching timeout override that verifies batch transactions honor an explicit timeout override.
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title 'Fix 29271' is vague and does not clearly convey the main change; it only references an issue number without describing what was fixed. Update the title to clearly describe the main change, such as 'Add maxWait and timeout options to batching $transaction method' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@yazan-abu-obaideh yazan-abu-obaideh marked this pull request as ready for review March 6, 2026 13:59
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 6, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
packages/client/src/runtime/core/types/exported/Extensions.ts (1)

298-302: 🧹 Nitpick | 🔵 Trivial

Extract the duplicated transaction options shape into a shared interface.

The same inline object type appears in both $transaction overloads (lines 298 and 302). Lift it into a reusable interface to avoid drift and to match the repository's TypeScript guideline for defining object shapes.

♻️ Suggested refactor
+export interface DynamicTransactionOptions<TypeMap extends TypeMapDef> {
+  maxWait?: number
+  timeout?: number
+  isolationLevel?: TypeMap['meta']['txIsolationLevel']
+}
+
 export type DynamicClientExtensionThisBuiltin<
   TypeMap extends TypeMapDef,
   TypeMapCb extends TypeMapCbDef,
   ExtArgs extends Record<string, any>,
 > = {
   $extends: ExtendsHook<'extends', TypeMapCb, ExtArgs, Call<TypeMapCb, { extArgs: ExtArgs }>>
   $transaction<P extends PrismaPromise<any>[]>(
     arg: [...P],
-    options?: { maxWait?: number; timeout?: number; isolationLevel?: TypeMap['meta']['txIsolationLevel'] },
+    options?: DynamicTransactionOptions<TypeMap>,
   ): Promise<UnwrapTuple<P>>
   $transaction<R>(
     fn: (client: Omit<DynamicClientExtensionThis<TypeMap, TypeMapCb, ExtArgs>, ITXClientDenyList>) => Promise<R>,
-    options?: { maxWait?: number; timeout?: number; isolationLevel?: TypeMap['meta']['txIsolationLevel'] },
+    options?: DynamicTransactionOptions<TypeMap>,
   ): Promise<R>

Per coding guidelines: **/*.{ts,tsx}: Use interface for defining object shapes in TypeScript.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b02a9ec5-75e1-443d-b6cc-2937baaf32a7

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa295d and 1dc0f6c.

📒 Files selected for processing (11)
  • packages/client-generator-js/src/TSClient/PrismaClient.ts
  • packages/client-generator-ts/src/TSClient/PrismaClient.ts
  • packages/client/src/runtime/RequestHandler.ts
  • packages/client/src/runtime/core/engines/client/ClientEngine.ts
  • packages/client/src/runtime/core/engines/common/Engine.ts
  • packages/client/src/runtime/core/request/PrismaPromise.ts
  • packages/client/src/runtime/core/types/exported/Extensions.ts
  • packages/client/src/runtime/getPrismaClient.ts
  • packages/client/tests/functional/issues/29271-batch-tx-timeout/_matrix.ts
  • packages/client/tests/functional/issues/29271-batch-tx-timeout/prisma/_schema.ts
  • packages/client/tests/functional/issues/29271-batch-tx-timeout/tests.ts

Comment thread packages/client/src/runtime/core/engines/client/ClientEngine.ts
Comment thread packages/client/tests/functional/issues/29271-batch-tx-timeout/tests.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/client/src/runtime/core/engines/client/ClientEngine.ts (1)

573-578: ⚠️ Potential issue | 🟠 Major

maxWait/timeout are still only materialized for multi batches.

This branch is the only place in requestBatch() that turns batch transaction.options into this.transaction('start', {}, txOptions). The compacted branch skips that step and runs with txInfo === undefined, so the new batch options still depend on which batch strategy the compiler picks.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fb4a8102-25ff-437f-94b1-cb0ae2853693

📥 Commits

Reviewing files that changed from the base of the PR and between 1dc0f6c and bed05b8.

📒 Files selected for processing (8)
  • packages/client-generator-js/src/TSClient/PrismaClient.ts
  • packages/client-generator-ts/src/TSClient/PrismaClient.ts
  • packages/client/src/runtime/RequestHandler.ts
  • packages/client/src/runtime/core/engines/client/ClientEngine.ts
  • packages/client/src/runtime/core/engines/common/Engine.ts
  • packages/client/src/runtime/core/request/PrismaPromise.ts
  • packages/client/src/runtime/core/types/exported/Extensions.ts
  • packages/client/src/runtime/getPrismaClient.ts

Comment thread packages/client/src/runtime/getPrismaClient.ts
Copy link
Copy Markdown
Contributor

@jacek-prisma jacek-prisma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this deserves to be covered with a test in packages/client/tests/functional/interactive-transactions/tests.ts

yazan-abu-obaideh and others added 2 commits March 26, 2026 13:23
Addressed review comments

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
addressed review comments
@yazan-abu-obaideh
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @jacek-prisma, I just added one. Let me know if there's anything else I can do 👍

@yazan-abu-obaideh
Copy link
Copy Markdown
Contributor Author

Hi @jacek-prisma! Any updates on the review?

@jacek-prisma jacek-prisma merged commit fbab4e8 into prisma:main Apr 9, 2026
250 of 253 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Behavior between Prisma 6 and Prisma 7 changed for sequential transaction timeouts in postgres

3 participants