Skip to content

Add ability to pass driver instance for Prisma Driver Adapters as before v6.6.0 #26885

Open

Description

@pasha-vuiko

Feature Summary

I would like to ask you to add the ability to pass DB driver instance into Prisma Driver Adapters as it was before Prisma v6.6.0, additionally to the current ability to pass driver options only.

Use Cases & Problem Description

It was very useful, it allowed to make an instance of DB connection pool with a DB driver outside of Prisma Adapter, and share the connection pool between Prisma and some third-party query builder to be able to write queries, that Prisma itself writes not very optimissed

Proposed Solution

Just use the previous interface, that was before the v6.6.0 so user can pass either a driver instance declared outside of the Prisma Adapter, or pass the driver options as in v6.6.0

Alternative Solutions

N/A

Potential Considerations

No response

Prisma Version

6.6.0

What part of Prisma does this affect?

Prisma Client

Additional Context

No response

Pre-Submission Checklist

  • I have searched existing issues to make sure this is not a duplicate
  • I have checked the Prisma roadmap to see if this is already planned
  • I have described why this belongs in Prisma Core rather than a solution in application code

Activity

  1. added
    kind/feature
    on Apr 13, 2025
  2. TimLinsenmayer commented on Apr 13, 2025

    @TimLinsenmayer

    Initially felt affected by this change as well, given that we use the pg Adapter to handle Managed Identity Authentication with Microsoft Azure (see Medium Article) when running in prod and otherwise falling back to a connection string in dev.

    After a closer evaluation we were able to tweak our code to migrate to the new path for those adapters.

    We used this in our codebase (now removed as this was a leftover, unwanted log collected):

    pool.on('error', (err) => {
        console.error('Pool error:', err);
    })
    const adapter = new PrismaPg(pool)
    

    Possible use case for this feature (at least for pg-Adapter) would be to respond to lifecycle events by the Pool instance passed (as seen here). Especially addding a listener to the error event is heavily encouraged by pg to prevent crashing the entire node process on error! (see the Callout in the linked documentation).

    For fellow devs, the error Argument of type 'Pool' is not assignable to parameter of type 'PoolConfig'. is caused by Prisma v6.6.0 and requires you to pass the instantiating options (new Pool{options}) into new PrismaPg({options}).

    In my opinion this change should be considered breaking (especially lacking legacy support for previous instantiation) and be highlighted as such.

  3. added
    bug/1-unconfirmed
    on Apr 16, 2025
  4. erwinv commented on May 2, 2025

    @erwinv
    Contributor

    I opened a PR that addresses this for the pg adapter. For those using PNPM, here's the PNPM patch targeting 6.7.0 (the latest version as of writing):

    @[email protected]

  5. ialpert commented on Jun 3, 2025

    @ialpert

    Relevant PRs:

    #27062
    #26935

  6. wodCZ commented on Jun 28, 2025

    @wodCZ

    I'd like to list another use-case: now that metrics preview feature is deprecated, we need a direct access to the driver adapter in order to see pool.waitingCount, pool.idleCount etc. to monitor the utilization.

    For anyone having the same need, I've found a way to access the adapter instance:

          const client = (await prisma._engine.adapterPromise).client;
          console.log(client.idleCount);
          console.log(client.totalCount);
          console.log(client.waitingCount);

    Obviously, it's dependent on private interface, which can change without notice, so use with caution.

  7. barryhagan commented on Jul 13, 2025

    @barryhagan
    Contributor

    Another argument for why pg.Pool should not be completely internal: #27641

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/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions