yWilliam
yWilliam
Explore posts from servers
PPrisma
Created by yWilliam on 7/20/2024 in #help-and-questions
Getting error when using Prisma Optimize
I am getting the below error when running my server with Prisma Optimize:
PS C:\Users\william\Desktop\GitHub\test> npm run dev

> test@4.0.0 dev
> next dev

▲ Next.js 14.2.5
- Local: http://localhost:3000
- Environments: .env

✓ Starting...
✓ Ready in 2.3s
○ Compiling /src/middleware ...
⚠ ./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/@prisma/extension-optimize/dist/index.js
./src/server/db.ts
./src/server/auth.ts
./src/app/api/auth/[...nextauth]/route.ts
┌─────────────────────────────────┐
│ See your Optimize dashboard at: │
https://optimize.prisma.io │
└─────────────────────────────────┘
PS C:\Users\william\Desktop\GitHub\test> npm run dev

> test@4.0.0 dev
> next dev

▲ Next.js 14.2.5
- Local: http://localhost:3000
- Environments: .env

✓ Starting...
✓ Ready in 2.3s
○ Compiling /src/middleware ...
⚠ ./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/@prisma/extension-optimize/dist/index.js
./src/server/db.ts
./src/server/auth.ts
./src/app/api/auth/[...nextauth]/route.ts
┌─────────────────────────────────┐
│ See your Optimize dashboard at: │
https://optimize.prisma.io │
└─────────────────────────────────┘
I'm using a T3-App which uses Next.js with TRPC:
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
import { env } from '@/env'
import { PrismaClient } from '@prisma/client'
import { withOptimize } from '@prisma/extension-optimize'

const createPrismaClient = () =>
new PrismaClient({
log: env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
}).$extends(withOptimize())

const globalForPrisma = globalThis as unknown as {
prisma: ReturnType<typeof createPrismaClient> | undefined
}

export const db = globalForPrisma.prisma ?? createPrismaClient()

if (env.NODE_ENV !== 'production') globalForPrisma.prisma = db
import { env } from '@/env'
import { PrismaClient } from '@prisma/client'
import { withOptimize } from '@prisma/extension-optimize'

const createPrismaClient = () =>
new PrismaClient({
log: env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
}).$extends(withOptimize())

const globalForPrisma = globalThis as unknown as {
prisma: ReturnType<typeof createPrismaClient> | undefined
}

export const db = globalForPrisma.prisma ?? createPrismaClient()

if (env.NODE_ENV !== 'production') globalForPrisma.prisma = db
Versions I'm using:
"@prisma/extension-optimize": "^0.10.0",
"prisma": "^5.17.0",
"@prisma/client": "^5.17.0",
"next": "^14.2.5",
"@prisma/extension-optimize": "^0.10.0",
"prisma": "^5.17.0",
"@prisma/client": "^5.17.0",
"next": "^14.2.5",
3 replies