Ririr
Ririr
PPrisma
Created by Ririr on 12/23/2024 in #help-and-questions
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! 🎅
10 replies