P
Prisma•2mo ago
Ririr

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

I have a NextJS 14 site running in local development. However, I run it using next dev -p 3002 --experimental-https as I need SSL for local testing. I have a very straightforward Prisma setup.
import { PrismaClient } from "@prisma/client";
import { withOptimize } from "@prisma/extension-optimize";
import { assertNonNullable } from "../types/misc";

declare global {
var __prisma: PrismaClient | undefined;
}

const optimizeApiKey = process.env.OPTIMIZE_API_KEY;

const useOptimize = process.env.PRISMA_OPTIMIZE === "true";

function createPrismaClient(usingOptimize = false) {
let prismaClient = new PrismaClient();

if (usingOptimize) {
console.warn(":rotating_light: Using optimize. Only in development !!!", optimizeApiKey);
assertNonNullable(optimizeApiKey, "Missing OPTIMIZE_API_KEY");

return new PrismaClient().$extends(
withOptimize({ apiKey: optimizeApiKey }),
);
}

return prismaClient;
}

let prisma: PrismaClient;

if (process.env.NODE_ENV === "production") {
prisma = createPrismaClient(useOptimize);
} else {
if (!global.__prisma) {
global.__prisma = createPrismaClient(useOptimize);
}
prisma = global.__prisma;
}

export default prisma;
import { PrismaClient } from "@prisma/client";
import { withOptimize } from "@prisma/extension-optimize";
import { assertNonNullable } from "../types/misc";

declare global {
var __prisma: PrismaClient | undefined;
}

const optimizeApiKey = process.env.OPTIMIZE_API_KEY;

const useOptimize = process.env.PRISMA_OPTIMIZE === "true";

function createPrismaClient(usingOptimize = false) {
let prismaClient = new PrismaClient();

if (usingOptimize) {
console.warn(":rotating_light: Using optimize. Only in development !!!", optimizeApiKey);
assertNonNullable(optimizeApiKey, "Missing OPTIMIZE_API_KEY");

return new PrismaClient().$extends(
withOptimize({ apiKey: optimizeApiKey }),
);
}

return prismaClient;
}

let prisma: PrismaClient;

if (process.env.NODE_ENV === "production") {
prisma = createPrismaClient(useOptimize);
} else {
if (!global.__prisma) {
global.__prisma = createPrismaClient(useOptimize);
}
prisma = global.__prisma;
}

export default prisma;
In the prisma.schema I have the following
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
I've checked the optimize API key, and I have a running query recording in the Prisma optimize dashboard. I do, however, still get the following error. [optimize] HTTP 409 Conflict: There is no active recording to write queries to. Please go to your dashboard at https://optimize.prisma.io and start a new recording. Is there something I'm missing? Thanks! 🎅
7 Replies
Nurul
Nurul•2mo ago
Hello @Ririr 👋 That's strange. Just to confirm, when you start a recording in your workspace, do you get this message "You have started a recording. Any query recorded from your application will appear here. Please run the queries in your application now."? Also, can you share your workspace id? It should be available in the URL: https://optimize.prisma.io/[workspaceid]
No description
Ririr
RirirOP•2mo ago
Yes. I do. Looks just like that.
Nurul
Nurul•2mo ago
Thanks for confirming. Can you share the workspace id? I'll share it with our Optimize team to debug this
Ririr
RirirOP•2mo ago
Absolutely @Nurul , it's `cm4txfo2402d4keppm6vsrdns`` And I could definetly be something on my side ... But love to get this working.
Nurul
Nurul•2mo ago
Thanks for sharing! I'll get this checked from our side. Meanwhile, can you double check the API key that you are using? I just want to confirm that the API key you are using belongs to the workspace in which you have started the recording.
Ririr
RirirOP•2mo ago
Damn! I was sure the key was correct. But to be 100% sure, I generated a new one, and things started working. Sorry. My mistake.
Nurul
Nurul•2mo ago
I am glad to hear that things started working! 🙂 Please let us know in case you have any feedback 🙌

Did you find this page helpful?