extension-read-replicas icon indicating copy to clipboard operation
extension-read-replicas copied to clipboard

Update package to work with prisma 6

Open shadoworion opened this issue 1 year ago • 7 comments

Update package to work with prisma 6

npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: @prisma/[email protected]
npm error node_modules/@prisma/client
npm error   @prisma/client@"6.0.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @prisma/client@"^5.2.0" from @prisma/[email protected]
npm error node_modules/@prisma/extension-read-replicas
npm error   @prisma/extension-read-replicas@"0.4.0" from the root project

shadoworion avatar Dec 02 '24 17:12 shadoworion

PR is here: https://github.com/prisma/extension-read-replicas/pull/42. You could test it and upvote it if it works for you. :-)

clemens avatar Dec 17 '24 10:12 clemens

From prisma 6.2+ it's not working at all.

TypeError: Cannot read properties of undefined (reading 'findFirst')
    at Array.$allOperations (/backend/node_modules/@prisma/extension-read-replicas/dist/index.js:146:34)
    at /backend/node_modules/@prisma/client-postgresql/runtime/library.js:31:9170
    at i (/backend/node_modules/@prisma/client-postgresql/runtime/library.js:121:1016)
    at PrismaPromise.then (/backend/node_modules/@prisma/client-postgresql/runtime/library.js:121:1091)

shadoworion avatar Jan 08 '25 15:01 shadoworion

Can confirm the current 0.4.0 version is not working on 6.2.1

 error     unhandledRejection: client.$disconnect is not a function
TypeError: client.$disconnect is not a function
    at /home/luke/github/podengine/pod-engine-monorepo/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/node_modules/@prisma/extension-read-replicas/dist/index.js:52:67

lukebelbina avatar Jan 11 '25 18:01 lukebelbina

Same here, it doesn't work with Prisma ^6.2.1


 TypeError: Cannot read properties of undefined (reading 'groupBy')
 TypeError: Cannot read properties of undefined (reading 'groupBy')
               at Array.$allOperations (file:///Users/meotimdihia/Sources/xxxxxxx/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@prisma/extension-read-replicas/dist/index.mjs:120:34)
               at /Users/meotimdihia/Sources/xxxxxxxx/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:31:9170
  

meotimdihia avatar Jan 18 '25 10:01 meotimdihia

For anyone running into issues with >= Prisma 6.2, you can get around it by initializing PrismaClients with the constructor and passing them into the extension as replicas, rather than urls.

    return client
        .$extends(
            readReplicas({
                replicas: (readonlyUrls ?? []).map((url) => new PrismaClient({ datasourceUrl: url })),
            })
        );

yharaskrik avatar Feb 02 '25 20:02 yharaskrik

Hey everyone!

We released a new version of read-replicas extension - 0.4.1.

https://www.npmjs.com/package/@prisma/extension-read-replicas

Can you please upgrade to the latest version and confirm if the issue is resolved?

nurul3101 avatar Mar 25 '25 11:03 nurul3101

@nurul3101 I confirm the problem was solved. I have been using it on high-traffic production for 2 days already.

meotimdihia avatar Mar 27 '25 23:03 meotimdihia

We've also been operating it in production for a while – seems fine.

clemens avatar Jun 17 '25 06:06 clemens