PrismaP
Prisma2y ago
25 replies
simnJS

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
import './lib/setup';
import { PrismaClient } from '@prisma/client/edge';
import { withOptimize } from '@prisma/extension-optimize';
import { container, LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

// Extend Prisma Client with the optimization extension
const prisma = new PrismaClient().$extends(withOptimize());

// Define a correct type for the extended Prisma Client
type ExtendedPrismaClient = PrismaClient & ReturnType<typeof withOptimize>;

// Sapphire client setup
const client = new SapphireClient({
  defaultPrefix: '!',
  caseInsensitiveCommands: true,
  logger: {
    level: LogLevel.Debug,
  },
  intents: [
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.Guilds,
    GatewayIntentBits.MessageContent,
  ],
  loadMessageCommandListeners: true,
});

// Main function to start the bot
const main = async () => {
  try {
    client.logger.info('Logging in');
    await client.login();
    client.logger.info('Logged in');
  } catch (error) {
    client.logger.fatal(error);
    await client.destroy();
    process.exit(1);
  }
};

// Ensure the container has the correct type
declare module '@sapphire/pieces' {
  interface Container {
    database: ExtendedPrismaClient; 
  }
} 

// Assign the database to the container
container.database = prisma as ExtendedPrismaClient;

// Execute the main function
void main();
Solution
Hey @simnJS

Which version of optimize are you using? Is it 0.10.0?
Was this page helpful?