Skip to content

Type inference is too slow when PrismaClient is union with TransactionClient #28967

Open

Description

@shahinghasemi

Bug description

Using prisma transaction client alongside of the prisma client is a common scenario, However I've recently noted that when I want to combine them, the types are not inferred immediately and causes typescript server to lag!!
Consider this code:

export const initPrisma = async (): Promise<PrismaClient> => {
  const client = await getPrismaClient(url);
  try {
    await client.$connect();
    console.info('::::Connected to DB::::');
    return client;
  } catch (error) {
    console.error('Cant connect to database: ', error);
  } finally {
    return client;
  }
};

async function something(tx?: Prisma.TransactionClient) {
  const client = await initPrisma()
  const combinedPrisma = tx ?? client ;

  // `combinedPrisma` type takes a considerable time to be inferred
  // while `PrismaClient` and `TransactionClient` alone are inferred immediately
}

In the code above when I type combinedPrisma and then . I expect the types/autocompletions get displayed immediately however it takes about 2 seconds in Mac and 5 seconds in Lenovo to show the types. It has been affecting my developer experience significantly!

Severity

🔹 Minor: Unexpected behavior, but does not block development

Reproduction

Expected vs. Actual Behavior

I expected the types get immediately shown however it takes unusual time.

Frequency

Consistently reproducible

Does this occur in development or production?

Only in development (e.g., CLI tools, migrations, Prisma Studio)

Is this a regression?

Don't know.

Workaround

Prisma Schema & Queries

Prisma Config

/// <reference types="node" />

import { defineConfig } from 'prisma/config';
const isTest = process.env.NODE_ENV === 'test';
const dbName = isTest ? 'ERPTEST' : 'ERP';

export default defineConfig({
  schema: './schema',
  migrations: {
    path: './migrations',
  },
  datasource: {
    url:
      process.env.DATABASE_URL ??
      `postgresql://postgres:password@localhost:5432/${dbName}`,
  },
});

Logs & Debug Info

None

Environment & Setup

  • OS: MacOS Tahoe
  • Database: Postgres
  • Node.js version: 24

Prisma Version

7.1.0

Activity

  1. coderabbitai commented on Dec 27, 2025

    @coderabbitai
    Contributor

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Related Issues

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    bug/1-unconfirmed
    on Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedkind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions