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
18 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.Hi @Nurul (Prisma), I tried your repo, is it still working on your end :)? Is there something about generating the keys that I need to be aware of? Cheers! (https://github.com/nurul3101/Optimize-NestJS/issues/2)
GitHub
No data appears in my Optimize Dashboard when following instruction...
Hi, I'm currently having some issues with using NestJS + Prisma Optimize and saw this repository. I started up a local PG server using docker-compose: services: nestjs-optimize-pg-db: image: po...
Yes it works for me π
Does it not work for you?
@Nurul Thanks for getting back π. It didn't for two days. but then I tried this morning, and now it works perfectly (https://github.com/nurul3101/Optimize-NestJS/issues/2#issuecomment-2440944354) π. I'm still trying to track down an issue in my original setup which is a bit different (first of all running mssql), so I'm trying to dig into it a little deeper.
GitHub
No data appears in my Optimize Dashboard when following instruction...
Hi, I'm currently having some issues with using NestJS + Prisma Optimize and saw this repository. I started up a local PG server using docker-compose: services: nestjs-optimize-pg-db: image: po...
It ended up working with mssql in a simple setup too, but still not in my original repository. So I started tearing my original repository apart to find out what was different, and while doing that, I discovered what caused the slow requests I had in the first place. Still didn't get optimize to work there though :/.