Issue with prisma optimize
Hello, I have an issue with prisma optimize
Error: prisma:client:operation span is expected to be entered in the client extension when tracing is enabled
at Array.$allOperations (C:\Users\simon\Desktop\diamond-presence\node_modules@prisma\extension-optimize\dist\index.js:4:1103)
at C:\Users\simon\Desktop\diamond-presence\node_modules@prisma\client\runtime\edge.js:5:5358
at i (C:\Users\simon\Desktop\diamond-presence\node_modules@prisma\client\runtime\edge.js:20:963)
at PrismaPromise.then (C:\Users\simon\Desktop\diamond-presence\node_modules@prisma\client\runtime\edge.js:20:1038)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.15.0
14 Replies
Up
Solution
Hey @simnJS
Which version of optimize are you using? Is it
0.10.0
?Could you try out using this dev version of optimize extension and check if the issue gets resolved?
@prisma/extension-optimize: 0.0.0-dev.202407222340
I will check ty
It work @Nurul !
I am glad to hear that this resolved the issue 🙌
Hi Nurul, I'm having an issue with Optimize version
0.10.1
: I pressed record, I initialized optimize and I don't see any rows displayed.
It seems to work though as, if I press 'stop recording', it tells me it cannot record because no of recording.
Any suggestions please ?https://www.loom.com/share/e1c6bfca5f4647a185124a78ddb34d7b here is a Loom where I explain the stack used
Hey @Virgile
Thanks for sharing the recording. Please allow me to share this with our Optimize team and get back to you with a solution.
thank you Nurul 🙂 appreciated
$extends returns a new client which you should use. Here you aren't using it. Could you try using the instance that you get when calling $extends. At the moment, you are discarding it.
Regarding the error:
the error they get when the recording is stopped is because the new client attempts to send the schema in the background even before they do any queries, but they aren’t actually using the optimize-enabled client themselves
Can you provide a code snippet please ? I don't understand
here is the code
Hi Nurul, I didn't quite understand your answer here. Sorry to notify you again but would really enjoy trying Prisma Optimize !
Hey, Apologies i missed your last message.
The main idea is that you should use the Prisma Client instance returned by the
withOptimize()
extension, which doesn't seem to be happening in your NestJS app.
Normally, you would do:
We are using the PrismClient instance that is being retuned by this line "new PrismaClient().$extends(withOptimize());"
In your case, you do this.$extends(withOptimize())
but doesn't use the value returned by it
Can you do something like const prisma = this.$extends(withOptimize()) or equivalent in your code and use the prisma
variable to perform database operations?I think we can do this yeah. But I think you should try it as well and add it to the docs, create a nestjs docs page ? For class base prisma
What do you think @Nurul (Prisma) ? So that when people have the same issue they know how to fix it.
I plan to make other videos using NestJS and Prisma, and I would like an easy fix in case people use paid features
Because I think it’s the same with accelerate
I agree that we should add this to our docs. I’ll try integrating Optimize in a Nest project and see what the workflow would look like.
We were able to make Optimize work with Optimize. If you instantiate PrismaClient in
OnModuleInit
like this:
https://github.com/nurul3101/Optimize-NestJS/blob/main/src/prisma.service.ts
The queries would show up in Optimize Dashboard.