P
Prisma•6d ago
leofc

How to remove `[optimize] HTTP 409 Conflict: There is no active recording to write queries to.`

My current client:
const prismaClientSingleton = (): PrismaClient => {
return new PrismaClient({
datasources: {
db: {
url: process.env.DATABASE_URL,
},
},
log: [{ emit: 'event', level: 'query' }],
}).$extends(
withOptimize({
apiKey: process.env.OPTIMIZE_API_KEY,
showNotification: false,
enable: process.env.PRISMA_OPTIMIZE_ENABLED === 'true',
}),
) as PrismaClient;
};
const prismaClientSingleton = (): PrismaClient => {
return new PrismaClient({
datasources: {
db: {
url: process.env.DATABASE_URL,
},
},
log: [{ emit: 'event', level: 'query' }],
}).$extends(
withOptimize({
apiKey: process.env.OPTIMIZE_API_KEY,
showNotification: false,
enable: process.env.PRISMA_OPTIMIZE_ENABLED === 'true',
}),
) as PrismaClient;
};
6 Replies
Prisma AI Help
Prisma AI Help•6d ago
You selected the bot's instantaneous insights. Let me compile your answer right away! The error [optimize] HTTP 409 Conflict: There is no active recording to write queries to. means that Prisma Optimize is trying to send query data, but there is no active recording session in the Optimize dashboard. How to resolve: 1. Start a Recording Session:
Go to the Prisma Optimize dashboard, log in, and click the Start recording button before running your app. Prisma Optimize only collects and analyzes queries during an active recording session. If you run your app without starting a recording, you'll see this 409 error because there's nowhere to send the query data [Getting Started]. 2. Stop the Error:
- Always ensure a recording is active before running your app with Optimize enabled. - If you want to avoid this error during development when not actively profiling, you can disable Optimize by setting PRISMA_OPTIMIZE_ENABLED to 'false' in your environment, so the extension does not attempt to send queries [FAQ]. Summary:
This error is expected if you run your app without an active recording session. Start a recording in the dashboard before running your app, or disable Optimize when not in use to prevent the error. If you need more help, check the Optimize docs or reach out on Discord. 🤔 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.
Nurul
Nurul•5d ago
Hey! The error occurs if you try to cpature queries when recording is not started. Are you running Prisma Optimize in your production environment? If yes, then you shouldn't. Prisma Optimize should be used only in development environments.
leofc
leofcOP•5d ago
@Nurul (Prisma) I am, in one specific server via an env variable. Even in a controlled production environment, is that a bad idea?
Nurul
Nurul•4d ago
Yes, I won't recommend running it in production environment
Nurul
Nurul•4d ago
(This is applicable for all databases, not only Prisma Postgres)

Did you find this page helpful?