P
Prisma2mo ago
Max

Basic Prisma Optimize Is Not Working

Hi, I'm am trying to debug some bad query performance in our application. I was going to use prisma optimize, but no matter what I it absolutely refuses to push anything the website. I have a VERY minimal example that does not work:
import {PrismaClient} from './generated/prisma';
import {withOptimize} from '@prisma/extension-optimize';

const prismaClient = new PrismaClient().$extends(withOptimize({apiKey: '<REDACTED>'}));
prismaClient.user.findFirst({
where: {
fullName: {
contains: 'hello world',
mode: 'insensitive'
}
}
});
import {PrismaClient} from './generated/prisma';
import {withOptimize} from '@prisma/extension-optimize';

const prismaClient = new PrismaClient().$extends(withOptimize({apiKey: '<REDACTED>'}));
prismaClient.user.findFirst({
where: {
fullName: {
contains: 'hello world',
mode: 'insensitive'
}
}
});
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id
fullName String
}
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id
fullName String
}
I get the output:
┌─────────────────────────────────┐
│ See your Optimize dashboard at: │
│ https://optimize.prisma.io |
└─────────────────────────────────┘
┌─────────────────────────────────┐
│ See your Optimize dashboard at: │
│ https://optimize.prisma.io |
└─────────────────────────────────┘
when running it with npx tsx ./src/index.ts In my actual app, I do get one query to show up, so its not like its not authenticating or anything. That one query is a $queryRawTyped I am using prisma v6.12.0, I also tried v6.6.0. Does Optimize not work with v6.6.0+? Do I just need to downgrade the optimize version? I am using the latest, 2.0.0.
10 Replies
Prisma AI Help
Prisma AI Help2mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! Based on the knowledge sources, Prisma Optimize is intended for use with Prisma Client v5.0.0 or higher, and the latest instructions reference compatibility up to at least v6.1.0, with special notes for versions between 4.2.0 and 6.1.0 regarding the tracing preview feature. There is no explicit documentation about incompatibility with v6.6.0+ or v6.12.0, nor about the need to downgrade the Optimize extension for these versions. However, there are known issues and limitations: - Prisma Optimize is designed for local development only, not for production use. Make sure you are running it in a local environment and have started a recording session in the Optimize dashboard. If you see the dashboard link but no queries appear, it often means no active recording session or the extension is not capturing queries as expected. You must click "Start recording" in the dashboard before running your queries for them to be captured Getting Started. - There are known compatibility issues with some preview features (e.g., typedSql) and with certain frameworks or build tools (e.g., Turbopack, Next.js with Turborepo) that may prevent Optimize from working correctly Known Limitations. - If you see only $queryRawTyped queries, this may be related to a known issue where Optimize does not capture all query types in some setups GitHub Issue. Recommendations: 1. Ensure you have started a recording session in the Optimize dashboard before running your script. 2. Double-check that your environment is local and not production. 3. If you are using any preview features or advanced build tools, try disabling them or running a minimal setup. 4. If the problem persists, it may be a compatibility issue with Prisma v6.6.0+ or the Optimize extension version, but the documentation does not confirm this. You may want to try with Pri sma Client v6.1.0 or v5.x as a test, or reach out on the Prisma Discord for further troubleshooting. The knowledge sources do not explicitly mention incompatibility with v6.6.0+ or a need to downgrade the Optimize extension. If you continue to experience issues, it may be an undocumented bug or limitation. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Max
MaxOP2mo ago
Tried 6.1.0, tried downgrading to extension-optimize@^1 Is this perhaps an account issue? I.e. do I need to buy Prisma pro or smth In the meantime I will make do with manually tracing things
Nurul
Nurul2mo ago
Hey Max! To confirm, once you start a recording in Optimize and start navigating your app and do Prisma queries, the queries do not show up in Optimize dashboard? Or is it that the queries show up but you do not get any recommendations?
Max
MaxOP2mo ago
So its inconsistent, i was getting one query when i tested in the prod app. It was a $queryRawTyped. But when i tested with an individual, isolated case (the example above). I didn't get anything. The issue seems to be with anything actually done by the prisma client, so client.someModel.someOperation rather than client.$someRawAction
Nurul
Nurul2mo ago
Hmm, that's strange 🤔 I haven't seen any other users report this. We are launching a new prisma version tomorrow, it would be interesting to see if the issue occurs with the new version as well
Max
MaxOP2mo ago
I will make sure to test it out. Could it be an account issue? Like free plan vs paid? Or that my account is too new or something?
Nurul
Nurul2mo ago
I don't think so. It should work on free plan as well.
Max
MaxOP2mo ago
Alright, thank you Hello, I have tried optimized again, and I have not been able to get anything. I have also checked that i can reach the ingestion endpoint @ optimize-ingestion.datacdn.workers.dev, and it is accessible to me. I started a recording session and had no dice. If it helps i am running on a mac. When I get off of work, I will try optimize again on my windows machine when I get home. On another note, when can we expect optimize to work with driver adapters? It did not work on my windows machine :/
Nurul
Nurul4w ago
Really weird 🤔
when can we expect optimize to work with driver adapters?
With Prisma 7, driver adapters would be the default way to interact with the databases, so at the point Optimize should work with driverAdapters as well
Max
MaxOP4w ago
kk

Did you find this page helpful?