P
Prisma5mo ago
yWilliam

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",
2 Replies
yWilliam
yWilliamOP5mo ago
With the original T3-Stack, just adding Prisma Optimize, the error occurs: https://github.com/WilliamBRDrive/test-prisma-optimize
GitHub
GitHub - WilliamBRDrive/test-prisma-optimize
Contribute to WilliamBRDrive/test-prisma-optimize development by creating an account on GitHub.
Nurul
Nurul5mo ago
Hi @yWilliam 👋 Thank you for giving Optimize a try, we are taking a look at the error you reported. Thank you for taking the time to share a reproduction.
Want results from more Discord servers?
Add your server